1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| $find = TrainRecord::find() // 表别名 ->alias('t') ->select(['t.train_record_id', 't.task_name', 't.project_id']) ->where(['t.user_id' => $user_id]) // like查询 ->andWhere(['like', 't.task_name', (string) $task_name]) ->andWhere(['=', 't.status', TrainRecord::STATUS_FINISH]) // width ->with(['project' => function ($query) { $query->alias('p')->select(['project_name']); }]);
$find ->andWhere(['>=', 't.create_time', $time]) ->andWhere(['<', 't.create_time', $time + 3600 * 24]);
$find // join ->joinWith(['project' => function ($query) { $query->alias('p')->select(['project_name']); }]);
|