-- 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.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to