1、Yii2获取当前程序执行的sql语句:

$query = model::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pagesize' => '25',
            ]
        ]);

//获取当前程序执行的sql语句

$query->createCommand()->getRawSql();
05-03 22:35