Zend framework query with innerjoin and AS
I try to Get the follow query into a valid zf query but I getting keep errors. I hope someone can help me with this one.
SELECT c1.id as c1id, c1.cat, c2.id,c2.sub_cat
FROM `categories`as c1
inner join categories as c2 on c2.cat = c1.cat开发者_Go百科
where c1.seo = 'tech'
Regards,
Nicky
Have you tried converting it into a Zend_Db_Select query?
$sel = $db->select();
$sel->from(array('c1' => 'categories'), array(
'c1id' => 'c1.id',
'c1.cat',
'c2.id',
'c2.sub_cat'
));
$sel->join(array('c2' => 'categories'), 'c2.cat = c1.cat', array());
$sel->where('c1.seo = ?', 'tech');
精彩评论