$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://gist.github.com/dcb9/e5fd296ba4bca16bf98c
最近更新博客有些频繁啊!
@大鹏:发现不错的东西,就顺便搬过来了~~~