将sql查询转换为Zend DB查询

时间:2011-09-02 17:28:17

标签: zend-framework

我有两张桌子: 文章 - 行业标准 如何将此查询转换为zend Db查询连接

$ SQL =“

SELECT article。*,sub_categoriesname_arabic AS sub_category_name_arabicsub_categoriesname_english AS sub_category_name_english,{{ 1}}。article AS sub_category_id FROM sub_categories_id                     LEFT JOIN article点击sub_categoriesarticle = sub_category_idsub_categories                     在idarticle = 1 “;

请帮助

谢谢

1 个答案:

答案 0 :(得分:0)

这应该可以解决问题:

$db->select()
   ->from('article', array('*', 'sub_categories_id' => 'sub_category_id')
   ->joinLeft(
        'sub_categories',
        'article.sub_category_id = sub_categories.id',
        array('sub_category_name_arabic' => 'name_arabic', 'sub_category_name_english' => 'name_english'))
   ->where('article.active = 1');