求助,关于DAO的操作 [ 新手入门 ]
需要查询三张表, 有没有系统自带的方法? 我自己写的代码可以实现, 虽然是后台, 也想知道yii有没有系统自带的方法. 我的代码:
public function getAppInformation($search,$pagesize){
$db = Yii::app()->db;
$sql = "select * from `app` as a inner join `user` as u on a.uid = u.id inner join `shop` as s on s.id = a.sid ";
$sql_num = "select count(*) as num from `app` as a inner join `user` as u on a.uid = u.id inner join `shop` as s on s.id = a.sid ";
if(isset($search['username'])){
$sql .= "and (where u.name like '%".$search['username']."%')";
}
if(isset($search['shopname'])){
$sql .= "and (where s.name like '%".$search['shopname']."%')";
}
if(isset($search['cid'])){
$sql .= "and (where a.cid=".$search['username'].")";
}
$sql .= "limit 0," . $pagesize;
$app = $db->createCommand($sql)->queryAll();
$num = $db->createCommand($sql_num)->queryScalar();
array_unshift($app,$num);
return $app;
}
CDbDataReader 这个方法里面我也试用了几个,好像不行...求解...跪拜...
共 1 条回复
latsu huoxing
注册时间:2012-09-04
最后登录:2014-05-28
在线时长:0小时20分
最后登录:2014-05-28
在线时长:0小时20分
- 粉丝0
- 金钱20
- 威望0
- 积分20