$query = new \yii\db\Query()这种写法,如何指定数据库? [ 2.0 版本 ]
$query = new \yii\db\Query();
$query->select('pa_call.id,pa_call.tableid,pa_call.time as msgtime,pa_table_area.id as areaid,pa_table_area.areaname as area,pa_table.tablename,pa_call.message as msg,pa_call.new as needoper,pa_call.status as isdone,pa_employee.username as oper')
->from(Call::tableName())
->join('LEFT JOIN',Table::tableName(),'pa_call.tableid=pa_table.id')
->join('LEFT JOIN',Area::tableName(),'pa_table_area.id=pa_table.areaid')
->join('LEFT JOIN',Employee::tableName(),'pa_call.employeeid=pa_employee.id')
->where($where);
$command = $query->createCommand();
$data = $command->queryAll();
共 4 个回答
-
zcx147716565 回答于 2017-05-05 16:35 举报
->from('table_name')
-
running-fly 回答于 2018-09-04 11:27 举报
(new \yii\db\Query())->select(['name','id'])
->from($gameName.'_nav') ->where(['is_del'=>0,'parent_id'=>0]) ->orderBy(['sort'=>SORT_ASC]) ->all($db); 在all方法里面指定
running-fly 觉得很赞
小程府 北京
注册时间:2016-03-23
最后登录:2021-02-09
在线时长:30小时31分
最后登录:2021-02-09
在线时长:30小时31分
- 粉丝13
- 金钱255
- 威望100
- 积分1555