<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                |版本|調整功能| |---|---| |5.0.5|添加`data`/`inc`/`dec`/`exp`方法設置數據| ## 更新數據表中的數據 ~~~ Db::table('think_user')->where('id', 1)->update(['name' => 'thinkphp']); ~~~ 如果數據中包含主鍵,可以直接使用: ~~~ Db::table('think_user')->update(['name' => 'thinkphp','id'=>1]); ~~~ > update 方法返回影響數據的條數,沒修改任何數據返回 0 如果要更新的數據需要使用`SQL`函數或者其它字段,可以使用下面的方式: ~~~ Db::table('think_user') ->where('id', 1) ->update([ 'login_time' => ['exp','now()'], 'login_times' => ['exp','login_times+1'], ]); ~~~ >[danger] `V5.0.18+`版本開始是數組中使用`exp`查詢和更新的話,必須改成下面的方式: ~~~ Db::table('think_user') ->where('id', 1) ->update([ 'login_time' => Db::raw('now()'), 'login_times' => Db::raw('login_times+1'), ]); ~~~ ## 更新某個字段的值: ~~~ Db::table('think_user')->where('id',1)->setField('name', 'thinkphp'); ~~~ > setField 方法返回影響數據的條數,沒修改任何數據字段返回 0 ## 自增或自減一個字段的值 `setInc/setDec` 如不加第二個參數,默認值為1 ~~~ // score 字段加 1 Db::table('think_user')->where('id', 1)->setInc('score'); // score 字段加 5 Db::table('think_user')->where('id', 1)->setInc('score', 5); // score 字段減 1 Db::table('think_user')->where('id', 1)->setDec('score'); // score 字段減 5 Db::table('think_user')->where('id', 1)->setDec('score', 5); ~~~ ## 延遲更新 `setInc/setDec`支持延時更新,如果需要延時更新則傳入第三個參數 下例中延時10秒,給`score`字段增加1 ~~~ Db::table('think_user')->where('id', 1)->setInc('score', 1, 10); ~~~ > setInc/setDec 方法返回影響數據的條數 ## 助手函數 ~~~ // 更新數據表中的數據 db('user')->where('id',1)->update(['name' => 'thinkphp']); // 更新某個字段的值 db('user')->where('id',1)->setField('name','thinkphp'); // 自增 score 字段 db('user')->where('id', 1)->setInc('score'); // 自減 score 字段 db('user')->where('id', 1)->setDec('score'); ~~~ ## 快捷更新(`V5.0.5+`) `V5.0.5+`以上版本封裝的`data`、`inc`、`dec`和`exp`方法屬于鏈式操作方法,可以配合`update`使用(官方推薦用法)。 下面舉個例子說明用法: ~~~ Db::table('data') ->where('id',1) ->inc('read') ->dec('score',3) ->exp('name','UPPER(name)') ->update(); ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看