<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                thinkphp 5 閉包函數使用詳解 舉個例子: ~~~ $this->where(function ($query) { $query->where('id', 1)->whereor('id', 2); })->find(); ~~~ 上述栗子就是一個簡單的where查詢的閉包函數使用,使用匿名函數添加復雜條件查詢, 最后執行的sql是: ~~~ // 加入上述代碼寫在user模型里,則執行的sql為: select * from user where (id = 1 or id = 2); ~~~ 其實閉包函數也不會復雜到哪去,無非帶參數不帶參數而已。 上面的例子加強一下: ~~~ $this->where(function ($query) use ($id1, $id2) { $query->where('id', $id1)->whereor('id', $id2); })->find(); ~~~ 這也就是thinkphp 5 里怎么使用閉包查詢傳參數的方法,使用use 傳入參數。 在thinkphp5模型的查詢中,一般有兩種方式:數組方式和閉包方式,相對于數組方式只能定義查詢條件,閉包方式可以支持更多的連貫操作,包括排序、數量限制等。 那么我們在使用閉包方式要怎么傳入參數呢?具體代碼如下: 普通閉包查詢: ~~~ $items = ItemModel::all(function($query){$query->order('sort', 'asc');}); ~~~ 帶參數的閉包查詢: ~~~ $items = ItemModel::all(function($query)use($type){ $query->where('type',$type)->order('sort', 'asc'); } ); ~~~ 通過代碼我們可以發現,在ThinkPHP5閉包查詢中傳參使用的是use傳遞。
                  <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>

                              哎呀哎呀视频在线观看