我该如何转左联接查询:

select advertisercontest.*, advertiseraccount.advertiserid, advertiseraccount.companyname
from advertisercontest
left join advertiseraccount on advertiseraccount.loginid = advertisercontest.loginid
where advertisercontest.golive is not NULL;

加入Zend的左联接?

最佳答案

你可以这样做:

    $db = Zend_Db_Table::getDefaultAdapter();

    $select = $db->select();
    $select->from('advertisercontest', '*')
            ->joinLeft(
                    'advertiseraccount',
                    'advertiseraccount.loginid = advertisercontest.loginid',
                    array('advertiseraccount.advertiserid', 'advertiseraccount.companyname')
                    )
            ->where('advertisercontest.golive is not NULL');;

    $result = $db->fetchAll($select);

    var_dump($result);

这是Zend_Db_Select documentation

10-08 19:23