Steven0T
- Steven0T 2017-09-24 已签到连续签到1天,获得了5个金钱
文档这里不是有吗?
也可以不用getSql();
在updateAll这个方法上点进去:OrderMain::updateAll($update_value, $update_where);
转到这段代码:
public static function updateAll($attributes, $condition = '', $params = []) { $command = static::getDb()->createCommand(); $command->update(static::tableName(), $attributes, $condition, $params); return $command->execute(); }
再点击execute()方法进去,转到
public function execute() { $sql = $this->getSql(); $rawSql = $this->getRawSql(); Yii::info($rawSql, __METHOD__); if ($sql == '') { return 0; }
然后在这一行打个断点: $rawSql = $this->getRawSql();
这里的$rawSql 就是原生sql;
这个对于增删改查都是实用的,还是要从原理出发哦不过个人还是用的是上面有个coder的方法
开启dev debug,然后URL:
http://yourDomain/debug- Steven0T 回答了问题 Yii2 如何输出 SQL 语句?
也可以不用getSql();
在updateAll这个方法上点进去:OrderMain::updateAll($update_value, $update_where);
转到这段代码:
public static function updateAll($attributes, $condition = '', $params = []) { $command = static::getDb()->createCommand(); $command->update(static::tableName(), $attributes, $condition, $params); return $command->execute(); }
再点击execute()方法进去,转到
public function execute() { $sql = $this->getSql(); $rawSql = $this->getRawSql(); Yii::info($rawSql, __METHOD__); if ($sql == '') { return 0; }
然后在这一行打个断点: $rawSql = $this->getRawSql();
这里的$rawSql 就是原生sql;
这个对于增删改查都是实用的,还是要从原理出发哦 - Steven0T 2017-09-22 已签到连续签到1天,获得了5个金钱