Order by column which is in another table zend framework
$db = Zend_Controller_Front::getInstance()->getParam('db');
$select = $db->select()->
from(array('item' => $type->getTableName()), 'id');
else if($orderBy == 'category_name')
$select->join(array('category' => 'categories'),
'item.category_id' == 'category.id', 'category_name')->order('category_name');
What is my problem, the database of the items consists of only 6 rows, and the categories table c开发者_开发知识库onsists of 11 rows. I get 66 rows (66 * 11), when what I really want is to just get 6 rows, ordered by the name of the category which is a column in another table(categories).
You can specify which table the column belongs to, i.e.,
->order('category.category_name');
精彩评论