问题描述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`, `
添加回答
举报
0/150
提交
取消