小程府 2017-01-10 10:28:08 3156次浏览 3条评论 4 1 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();
觉得很赞
您需要登录后才可以评论。登录 | 立即注册