0

I'm not sure how to do this: My Post model is extending Zend_Db_Table_Abstract and I'm working on my homepage right now, where I want to show every post from the DB. The documentation says that fetchAll() and fetchRow are deprecated, and that I should use Zend_Db_Select. I've read through the manual, but I don't really see how this is used in combination with Zend_Db_Table_Abstract? Or do I just make an instance and start writing queries 'out of nowhere'? Because I'd like to acces my data through my Model...

Am I missing something?

1 Answers1

1

They are not deprecated, the use on them is the one that changed, for example, before you could pass a where clause and a order clause, the correct way to do that is use a Select:

public function getNewOrdersByDate()
{
     $Select = $this->select();
     $Select->where('status=?', 'new')->order('created ASC');

     return $this->fetchAll($Select);
}
Chris
  • 884
  • 5
  • 8
  • i.e. Zend_Db_Table_Abstract has a select() method which will return a Zend_Db_Select object which will SELECT from whichever table the Zend_Db_Table_Abstract instance represents. – jah Jan 20 '11 at 20:37
  • are joins possible then? i don't see how if it only selects from the table it represents... thanks! –  Jan 20 '11 at 21:18
  • No, in that case you must do something like: $Select = $this->getAdapter()->select() and then use $this->getAdapter()->fetchAll($Select); The problem is that using a join leaves a Zend_Db_Table_Row with more columns that it has. In the manual there is a example to use it, or use a readonly object. – Chris Jan 21 '11 at 03:31