$query = (new Query()) //->select('bl.id,pp.id as point_id, , p.name as proj_name, pt.name as patrol_type, bl.full_name') ->select(['bl.id','pp.id as point_id','pp.name','p.name as proj_name','bl.full_name',"( SELECT GROUP_CONCAT(`name` SEPARATOR '; ') FROM pb_patrol_type WHERE CONCAT(';', pp.patrol_type_id, ';') LIKE CONCAT('%;', id, ';%') ) AS patrol_type"]) ->from('pb_patrol_point pp') ->leftJoin('pb_base_location bl', 'bl.id = pp.location_id') ->leftJoin('pb_patrol_type pt', 'pt.id = pp.patrol_type_id') ->leftJoin('t_project p', 'p.id = pp.proj_id') ->where([ 'pp.is_deleted' => 0]) ->andWhere(['pp.proj_id' => $proj_id]); $query2 = $query; $list['total'] = count($query->createCommand($this->getDb())->queryAll()); if (isset($model)) { $query = $query ->offset($model->skip) ->limit($pageSize); } $list['items'] = $query->createCommand($this->getDb())->queryAll(); return $list;

分类: web

标签: