原生sql使用备忘 [ 2.0 版本 ]
方式一:
$connection = Yii::$app->db;
$sql = "select * from hd_article where aid<".$aid." order by aid desc limit 1";
$command = $connection->createCommand($sql);
$res = $command->queryAll($sql);
方式二:
$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();
小程府 北京
注册时间:2016-03-23
最后登录:2021-02-09
在线时长:30小时31分
最后登录:2021-02-09
在线时长:30小时31分
- 粉丝13
- 金钱255
- 威望100
- 积分1555
共 3 条评论
马克一下,以后使用!
眼眼眼眼眼abcde
sql眼眼