To add another answer to this question ...
Zend provides various ways to access data. It's easier for me to work with arrays in Zend, as it makes your code more portable.
Using Zend_Db_Table_Abstract:
class Model_MyStuff extends Zend_Db_Table_Absract { protected $_name = 'Stuff'; protected $_primary = 'StuffID'; function getStuff() { $select = $this->select(); $select->where('Active = 1'); $results = $select->query()->fetchAll(); if (count($results) > 0) return $results; return null; } }
This code will return an array instead of objects that can be immediately passed to json_encode. The difference is that you are requesting a fetchAll ($ query) object, while I select select for the query () -> fetchAll (). I believe that for this you need to select a select object from $ this-> select ().
source share