alias('a'); $deviceFind->select(['a.*', 'm.name as manufacture','p.name as project','pd.name as production','mo.name as model']); $deviceFind->leftJoin('manufacture as m', 'm.manufacture_no = a.manufacture_no'); $deviceFind->leftJoin('project as p', 'p.project_no = a.project_no'); $deviceFind->leftJoin('model as mo', 'mo.model_no = a.model_no'); $deviceFind->leftJoin('production as pd', 'pd.production_no = a.production_no'); $deviceFind->where($where); $deviceFind->orderBy('created_at desc'); $deviceFind->asArray(); if ($offset) { $deviceFind->offset($offset); } if ($limit) { $deviceFind->limit($limit); } $all = $deviceFind->all(); return $all; } /** * @param $where * @return int|string */ static function getListCount($where) { $deviceFind = DeviceAuthFailModel::find(); $deviceFind->alias('a'); $deviceFind->leftJoin('manufacture as m', 'm.manufacture_no = a.manufacture_no'); $deviceFind->leftJoin('project as p', 'p.project_no = a.project_no'); $deviceFind->leftJoin('model as mo', 'mo.model_no = a.model_no'); $deviceFind->leftJoin('production as pd', 'pd.production_no = a.production_no'); $deviceFind->where($where); $all = $deviceFind->count(); return $all; } /** * @param $condition * @return array|\yii\db\ActiveRecord[] */ static function findAll($condition) { $deviceModel = DeviceAuthFailModel::find(); $deviceModel->where($condition); $list = $deviceModel->all(); return $list; } }