2011-09-02 148 views
0

我拖表: 文章, - 行業標準 如何將這個查詢轉換爲Zend的Db的查詢加入轉換SQL查詢的Zend DB查詢

$ SQL =」

選擇article *,sub_categoriesname_arabic。 AS sub_category_name_arabicsub_categoriesname_english AS sub_category_name_englisharticlesub_category_id AS sub_categories_id FROM article LEFT JOIN sub_categories ON articlesub_category_id = sub_categories。其中articleactive = 1 「;

請需要幫助

由於關於

回答

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