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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                可以對模型的查詢和寫入操作進行封裝 例如: ~~~ <?php namespace app\model; use think\Model; class User extends Model { public function scopeThinkphp($query) { $query->where('name','thinkphp')->field('id,name'); } public function scopeAge($query) { $query->where('age','>',20)->limit(10); } public function scopeEmail($query, $email) { $query->where('email', 'like', '%' . $email . '%'); } } ~~~ 就可以進行下面的條件查詢: ~~~ // 查找name為thinkphp的用戶 User::scope('thinkphp')->find(); // 查找年齡大于20的10個用戶 User::scope('age')->select(); // 查找name為thinkphp的用戶并且年齡大于20的10個用戶 User::scope('thinkphp,age')->select(); ’ //如果有額外參數則使用如下 // 查詢email包含thinkphp和分數大于80的用戶 User::email('thinkphp')->score(80)->select(); //或者閉包函數 User::scope(function($query){ $query->where('age','>',20)->limit(10); })->select(); ~~~ >[danger]使用查詢范圍后,只能使用`find`或者`select`查詢。 # **全局查詢范圍** 支持在模型里面設置`globalScope`屬性,定義全局的查詢范圍 ~~~ <?php namespace app\model; use think\Model; class User extends Model { // 定義全局的查詢范圍 protected $globalScope = ['status']; public function scopeStatus($query) { $query->where('status',1); } } ~~~ 然后,執行下面的代碼: ~~~ $user = User::find(1); ~~~ 最終的查詢條件會是 ~~~ status = 1 AND id = 1 ~~~ 如果需要動態關閉所有的全局查詢范圍,可以使用: ~~~ // 關閉全局查詢范圍 User::withoutGlobalScope()->select(); ~~~ 可以使用`withoutGlobalScope`方法動態關閉部分全局查詢范圍。 ~~~ User::withoutGlobalScope(['status'])->select(); ~~~
                  <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>

                              哎呀哎呀视频在线观看