$u = new Users();
$results = $u->fetchAll($u->select()->order('name'));
$users = array();
foreach ($results as $record) {
$users[$record->id] = $record->toArray();
}
You can encapsulate this logic in a function in your class, something like fetchSorted($order)
function fetchSorted($order) {
$results = $this->fetchAll($this->select()->order($order));
$users = array();
foreach ($results as $record) {
$users[$record->id] = $record->toArray();
}
return $users;
}
HTH
Nikolaos
--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.
On Fri, Dec 12, 2008 at 00:55, Dan Wilson <dan@acucore.com> wrote:
On Thu, Dec 11, 2008 at 11:19 AM, Nikos Dimopoulos <nikos@niden.net> wrote:This doesn't work. Even if it did try to make the column specified in
> I believe something like this will work:
> $u = new Users();
> $results = $u->fetchAll($u->select()->order('name'));
>
> $users = $results->toArray();
> (Not tested but it should work).
> Users is a class that extends Zend_Db_Table_Abstract with a $_name = 'User'
the order as the key index, there's no reason why that would be
unique. Any other ideas?
-=Dan
--
The contents of this message may contain confidential or privileged information and is intended solely for the recipient(s). Use or distribution to and by any other party is not authorized. If you are not the intended recipient, copying, distribution or use of the contents of this information is prohibited.
没有评论:
发表评论