First, if you are looking for a category by its primary key, it is easier to use the find() method:
$id = (int) $this->_request->getParam('id'); $category = new Default_Model_Categorys(); $this->view->category = $category->find($id)->current();
Secondly, to limit or sort dependent Category_Info strings, you can use the Zend_Db_Table_Select object as an optional findDependentRowset() parameter. Here is an example:
$select = $category->select()->where("info_type = 'PRICE'") ->order("info_date") ->limit(3); $categoryInfo = $this->view->category->findDependentRowset( 'Default_Model_CategoryInfo', null, $select);
Note that you can use any table object to create this select object. Since the FROM for this selection will be set using the findDependentRowset() method, you simply add other clauses and then pass it.
PS: You donβt need to declare $_dependentTables at all unless you intend to use cascading updates or cascading deletes via PHP code. I highly recommend doing this - itβs much more efficient to allow RDBMS to handle these cascading operations.
You also do not need to declare $_primary if the primary key constraints are indeed declared in the database tables. Zend_Db_Table_Abstract knows how to check metadata to get primary key columns.
source share