Anders Gunnarsson a écrit :
Thanks, that worked fine!

A performance question then:
Is there a better/faster way for only accessing data then using rowsets?
I usually only need raw data access.

Can I make another type of fetchAll, that skips all Table Data Gateway pattern - stuff,
and save computing time/power?


You can do :

$this->getAdapter()->getConnection()->exec($sql);

or

$this->getAdapter()->query($sql)






Matthew Weier O'Phinney wrote:
-- Anders Gunnarsson <[EMAIL PROTECTED]> wrote
(on Monday, 10 December 2007, 09:46 AM +0100):
When I use the fetchAll-method inside a modelclass (MessageThreads) like this:
$this->fetchAll();
I get a Zend_Db_Table_Rowset Object

But if I do this:
$this->getAdapter()->query("SELECT * FROM messageThreads")->fetchAll();
I just get an associative Array (but with the same data)

Can I get them to return the same?

You can always cast the results of the latter call to a
Zend_Db_Table_Rowset:

    return new $this->_rowsetClass(array(
        'table'    => $this,
        'rowClass' => $this->_rowClass,
'data' => $this->getAdapter()->query("SELECT * FROM messageThreads")->fetchAll(),
        'stored'   => true
    ));


If I set the examples to a view-object I can loop both,
but the second gives me an error "Trying to get property of non-object",
when getting the values.

Right -- because calling fetchAll() on a zend_db_adapter object returns
an associative array; db adapters are meant for basically raw data
access. Zend_Db_Table works differently as it is implementing a Table
Data Gateway pattern, which returns rowsets of Row Data Gateways --
which allow you to write business logic surrounding returned results and
inserting/updating results.




--
Laurent Melmoux - [EMAIL PROTECTED]
Annecy - France

Reply via email to