Why yii uses CDbCriteria classes, $ criteria

150 3

This is a method I wrote in the model file. I'd like to make a table ( t ) and another table c to join ( left join ).

 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();
 }

But the data that's now is like this.

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
 }

All these fields are the fields in the t table and there's no leftjoin for the table, which is why?

1 Answers

135 4

I've encountered a problem with you, how do you solve it.

...