$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'
HTH
Nikolaos
On Thu, Dec 11, 2008 at 13:05, Dan Wilson <dan@acucore.com> wrote:
Hey all,
I'm new to Zend_Db... converting from Doctrine. Doctrine had a cool
features [1] where you could indicate the column you want to index
your resulting array by. Is there any way to easily duplicate this in
Zend_Db?
Example:
CREATE TABLE User (id int, name varchar, phone varchar);
INSERT INTO User (1, 'Pete', '555-555-5555');
INSERT INTO User (2, 'George', '555-555-5555')
INSERT INTO User (3, 'Harry', '555-555-5555')
$q = Doctrine_Query::create();
$q->from('User u INDEXBY u.name');
$users = $q->execute(Doctrine::HYDRATE_ARRAY);
The resulting array would be like the following:
$users[1] = array('id' => 1, 'name' => 'Pete', 'phone' => '555-555-5555');
etc....
Thanks,
-=Dan
[1] http://www.doctrine-project.org/documentation/manual/1_0/en/dql-doctrine-query-language#indexby-keyword
--
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.
没有评论:
发表评论