Saturday, October 18, 2014

find('all') with results using id as the index instead of 0,1,2,3,...

Hello,

I seem to be rewriting the same code over and over... which, of course, is really a waste of time...
What I'm using a lot is the results of a find all that is indexed by the id field.

find all returns:
[0] => array( id => 178, otherdata => 'something 178')
[1] => array(id => 55, otherdata => 'data for 55')

etc.

I want:
[178] => array(otherdata => 'something 178')
[55] => array(otherdata => 'data for 55')

Now of course I can loop through the results array and build the second but it seems that I'm missing something in Cake.  Is there something in Cake that would take care of this more "automagically?"

Thanks in advance for any assistance,
glk

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: