Yii2打印原始sql语句

$query = User::find() ->where(['id'=>[1,2,3,4]) ->select(['username'])

// get the AR raw sql in YII2

$commandQuery = clone $query;

echo $commandQuery->createCommand()->getRawSql();

$users = $query->all();
原文地址:https://www.cnblogs.com/dongruiha/p/9440620.html