You have a many-to-many relationship between books and categories, and the placement table is the intersection table. Thus, I think that one way your $ select can be created is to use an internal join as follows:
$placementModel = new Your_Model_Table_Placement(); $select = $placementModel->select(Zend_Db_Table::SELECT_WITH_FROM_PART)->setIntegrityCheck(false); $select->joinInner('BOOKS', 'BOOKS.book_id = PLACEMENT.placement_book_id'); $select->where('PLACEMENT.placement_category_id = ?', $categoryID); $adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
Directly, the names of the tables and models should match your real names. Another way is to create a view in your database. Then you create a model for the view. That would make $ select shorter.
source share