Home  >  Article  >  PHP Framework  >  How to print sql in yii

How to print sql in yii

尚
Original
2019-12-17 13:48:373000browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn