2009年7月24日星期五

Re: [fw-db] Zend_DB_Table_Select and fetchPairs

My attempt is to write clear and short code.
If I want to store a recordset in a simple assoc array, fetchPairs is a perfect solution.
fetchall() would require the fetch and a loop afterwards.

solution for me is:
(you have one or more Zend_DB_Table objects if you are using Zend_Db_Table_Select),
just make
$myZend_Db_Table->getAdapter->fetchPairs($objectZend_Db_Table_Select);

don't know why Zend_Db_Table does not implement / inherit the fetchPairs method directly, but this way works.
(OK, in my project every table instance inherits a project base class which itself inherits   Zend_Db_Table_Abstract,
so I could easily give "direct" call-access to my Zend_Db_Table instances by "implenting" the fetchPairs method,  the question is know, why isn't it yet implemented in the Zend_Db_Table class).


Ralph Schindler schrieb:
The closest I think you can get it like so:

$select->...->query(Zend_Db::FETCH_NUM);

But ultimately, if querying through Zend_Db_Table, you tend to get Zend_Db_Table_Rows back, and this is by design.

What are you attempting to do exactly?

-ralph

Mathias Grub wrote:
Hello,

is there a possibility to use the Zend_DB::fetchPairs method with the Zend_Db_Table_Select object?

thanks for any hints.



没有评论: