zoukankan      html  css  js  c++  java
  • yii的数据库相关操作

    获取某一列数据

     self::find()->where(['pid'=>$this->id])->select('id')->column();

    更新操作

    $model->updateAttributes(['sales_status'=>Sales::SALES_STATUS_REFUND]) === false

    $updateRes = UllageGoodsModel::updateAll(['is_deleted' => 1], ['ullage_goods_id' => $diffIdArr])
    public function update ($runValidation = true, $attributeNames = null)
        {
            if($runValidation && ! $this->validate($attributeNames))
            {
                return false;
            }
            return $this->updateInternal($attributeNames);
        }

    updateInternal不需要验证

     $model->check_user_name = $userInfo->user_name;
     $model->check_user_id = $userInfo->user_id;
     if (!$model->update()) {}或$model->update(false, ['is_deleted']) === FALSE

    updateCounters您可以使用 updateCounters()更新一个或多个计数列;参考

    $post = Post::findOne(100);
    
    // UPDATE `post` SET `view_count` = `view_count` + 1 WHERE `id` = 100
    $post->updateCounters(['view_count' => 1]);

    Note that this method differs from updateAllCounters() in that it only saves counters for the current AR object

    public static integer updateAllCounters($counters, $condition = '')

     

  • 相关阅读:
    windows下安装python模块
    红包demo
    如何查看python 的api
    vscode 与 python 的约会
    默认构造函数
    关于重载
    转类型转换
    asm-offset.h 生成
    debian 7 安装
    emacs 定制进缩风格
  • 原文地址:https://www.cnblogs.com/zhiguopingtianxia/p/10294299.html
Copyright © 2011-2022 走看看