开发者

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜