php - yii2.0的curd
巴扎黑
巴扎黑 2017-04-10 16:52:59
0
3
206

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

巴扎黑
巴扎黑

reply all(3)
刘奇
echo (new \yii\db\Query)->from('users')
    ->where(['name'=>'moca'])
    ->createCommand()
    ->rawSql; // 同getRawSql()

输出

SELECT * FROM `users` WHERE `name`='moca'

yii-db-command

巴扎黑

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


在 web/index.php

defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
PHPzhong

$obj->primaryKey;
可以获取$obj->save()的主键

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template