Home > Article > PHP Framework > How to print sql in yii
If you want to print Sql, you can replace the commands you want to execute such as queryAll(), queryOne(), execute() with getRawSql();
For example :
If you want to see
$result = Yii::$app->db->createCommand()->update('table', ['name' => $name], "id = {$id}")->execute();
, you can use
echo $sql = Yii::$app->db->createCommand()->update('table', ['name' => $name], "id = {$id}")->getRawSql();
to print it
PHP Chinese website, there are a lot of free Yii introductory tutorials, everyone is welcome to learn!
The above is the detailed content of How to print sql in yii. For more information, please follow other related articles on the PHP Chinese website!