yii2.0的curd

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:17:20
Original
1414 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:
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template