yii2.0的curd

WBOY
Release: 2016-06-06 20:17:20
Original
1392 people have browsed it

yii2.0中有没有一个像tp中的getLastSql()方法去查询执行后的sql语句

回复内容:

yii2.0中有没有一个像tp中的getLastSql()方法去查询执行后的sql语句

<code>echo (new \yii\db\Query)->from('users')
    ->where(['name'=>'moca'])
    ->createCommand()
    ->rawSql; // 同getRawSql()</code>
Copy after login

输出

<code>SELECT * FROM `users` WHERE `name`='moca'
</code>
Copy after login

yii-db-command

这个不清楚,不过可以使用debug模式,查看运行的状态,和执行的SQL信息


在 web/index.php

<code>defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');</code>
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template