Steven0T

Steven0T

微信公众号:佛系Coder

  • 财富值2970
  • 威望值160
  • 总积分4850

个人信息

  • 发布了话题
    Yii2使用驼峰命名的形式访问控制器
  • 回复了 的回复

    怎么改的大侠

    我的博客有回答

  • 2017-09-24 已签到
    连续签到1天,获得了5个金钱
  • 文档这里不是有吗?
    企业微信截图_15060671788737.png

  • 回复了 的回答

    也可以不用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

  • 也可以不用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;
    这个对于增删改查都是实用的,还是要从原理出发哦

  • 2017-09-22 已签到
    连续签到1天,获得了5个金钱
总监 等级规则
4850/5000
资料完整度
70/100
用户活跃度
0/100

Ta的关注

3

Ta的粉丝

10

Ta的访客

30