0
加盟這是mysqli的查詢做不到內蒙古中CDbCriteria
SELECT DISTINCT t.company_id,t.image,t.text,t.date, t.title AS c_title
FROM news t
INNER JOIN companies c ON c.company_id=t.company_id ORDER BY t.date DESC
LIMIT 20" or die ("ERROR ". mysqli_error($link));
我想在CDbCriteria
$Criteria = new CDbCriteria();
$Criteria->join = 'INNER JOIN companies c ON t.company_id=c.company_id';
if ($place>0){
$Criteria->condition = "t.company_id = :place";
$Criteria->params = array(':place'=>$place);
}
$Criteria->order = "t.date DESC";
$Criteria->limit = 20;
$Criteria->select='t.company_id,t.image,t.text,t.date,c.title AS c_title';
$dataProvider = new CActiveDataProvider('News',
array(
'criteria'=>$Criteria,
'pagination'=>false
)
);
Error屬性 「News.c_title」 沒有定義
你在一個網格/列表視圖中使用呢?如果是這樣,請添加它。 – topher
不,問題是我不能從公司拿到c.title,它在新聞表中找它 – user3434212