联表查询,看看错误! [ 新手入门 ]
$criteria=new CDbCriteria();
$criteria->select='news_title,username,pl_id,pl_content,pl_time';
$criteria->join='JOIN pinglun ON news_id =pl_int JOIN users ON id=pl_person';
$criteria->order='pl_id DESC';
$dataProvider = new CActiveDataProvider('News',array( 'pagination'=>array( 'pageSize'=>8)));
$this->render('index',array(
'dataProvider'=>$dataProvider,
));
共 2 条回复
-
lz19881123 回复于 2012-01-05 10:36 举报
$sql="select pl_id,pl_content,pl_time,news_title,username from news join pinglun on news_id=pinglun.pl_int left join users on id=pl_person order by pl_id desc"; $art=Yii::app()->db->createCommand($sql); $data=$art->queryAll(); $dataProvider = new CActiveDataProvider($data);
这种写法对吗?
-
lz19881123 回复于 2012-01-05 10:36 举报
请老鸟看看!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!:lol
lz19881123 深圳
注册时间:2011-07-26
最后登录:2019-05-26
在线时长:7小时52分
最后登录:2019-05-26
在线时长:7小时52分
- 粉丝37
- 金钱1030
- 威望0
- 积分1100