I’m trying to access rows of a fetchAll call (returns Zend_Db_Table_Rowset_Abstract) by a row’s primary key.
I was wondering what would be the easiest way of doing this, besides looping through and finding the desired row.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I recall correctly,
Zend_Db_Table_Rowset_Abstractis just passed an array (or something that acts like one), then as you iterate through it, it creates theZend_Db_Table_Row_Abstractobjects.The best way may be to loop through once, and store the rows in an array, indexed by the primary key. That way you do one loop, then can access any row by the key.
Update: Just took a look at the source, here’s data that’s (eventually) passed to the rowset object:
When you iterate through the rowset for the first time, that original array is used to create the row objects. The data hasn’t been looped through before that point, so you’re not doing something that’s already been done.
So you have to do something like this to map rows to primary key (I haven’t used
Zend_Db_*for a while, treat this a pseudocode):Of course you can extend the abstract rowset class and do this internally if you want.