这个是我在model文件里面写的一个方法。我想将一张表(t) 和 另一张表 c 做外连接(left join)。
<code> public function pagination($limit, $condition, $order){ $criteria = new CDbCriteria(); $criteria->alias = 't'; $criteria->order = $order; $criteria->select = 't.id, c.value'; $criteria->addCondition($condition); $criteria->join = 'left join lp_site_conf as c on t.type=c.id'; $result['listInfo'] = YiiData($this->findAll($criteria)); $result['pageCount'] = $pages->getPageCount(); }</code>
但是 现在查出来的数据是这样的
<code>array(10) { [0] => array(9) { ["id"] => string(2) "10" ["name"] => NULL ["type"] => NULL ["createuid"] => NULL ["createtime"] => NULL ["modifytime"] => NULL ["description1"] => NULL ["description2"] => NULL ["status"] => NULL } [1] => array(9) { ["id"] => string(1) "9" ["name"] => NULL ["type"] => NULL ["createuid"] => NULL ["createtime"] => NULL ["modifytime"] => NULL ["description1"] => NULL ["description2"] => NULL ["status"] => NULL }</code>
这些字段都是t表中的,根本没有leftjoin的表的字段,这是什么原因?
这个是我在model文件里面写的一个方法。我想将一张表(t) 和 另一张表 c 做外连接(left join)。
<code> public function pagination($limit, $condition, $order){ $criteria = new CDbCriteria(); $criteria->alias = 't'; $criteria->order = $order; $criteria->select = 't.id, c.value'; $criteria->addCondition($condition); $criteria->join = 'left join lp_site_conf as c on t.type=c.id'; $result['listInfo'] = YiiData($this->findAll($criteria)); $result['pageCount'] = $pages->getPageCount(); }</code>
但是 现在查出来的数据是这样的
<code>array(10) { [0] => array(9) { ["id"] => string(2) "10" ["name"] => NULL ["type"] => NULL ["createuid"] => NULL ["createtime"] => NULL ["modifytime"] => NULL ["description1"] => NULL ["description2"] => NULL ["status"] => NULL } [1] => array(9) { ["id"] => string(1) "9" ["name"] => NULL ["type"] => NULL ["createuid"] => NULL ["createtime"] => NULL ["modifytime"] => NULL ["description1"] => NULL ["description2"] => NULL ["status"] => NULL }</code>
这些字段都是t表中的,根本没有leftjoin的表的字段,这是什么原因?
我遇到了和你一样的问题,你是怎么解决的呢?