I have tow table : article,sub_categories how to convert this query to zend Db query join
$sql="
SELECT article
.*, sub_categories
.name_arabic
AS sub_category_开发者_Go百科name_arabic
, sub_categories
.name_english
AS sub_category_name_english
, article
.sub_category_id
AS sub_categories_id
FROM article
LEFT JOIN sub_categories
ON article
.sub_category_id
= sub_categories
.id
WHERE article
.active
= 1
";
Please need help
Thanks with regard
This should do the trick:
$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');
精彩评论