Yii2开发中,使用关联查询with后,怎么打印执行执行sql呢?
echo $lesson->createCommand()->getRawSql();die;
$model = CrmLesson::find() ->where(['id' => $lessonId]) ->with([ 'class' => function (ActiveQuery $query){ $query->select('id, num_code'); } ]) ->select(['id as lesson_id', 'classroom_id', 'type', 'class_id', 'title', 'teacher', 'teacher_assistant', 'open_time as start_time', 'end_time']) ->asArray();echo $lesson->createCommand()->getRawSql();die;
SELECT `id` AS `lesson_id`, `classroom_id`, `type`, `class_id`, `title`, `teacher`, `teacher_assistant`, `
繁星coding
相关分类