开发者

Zend framework query with innerjoin and AS

开发者 https://www.devze.com 2023-04-06 06:30 出处:网络
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.

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

精彩评论

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

关注公众号