<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 功能強大 支持多語言、二開方便! 廣告
                >[danger] 搜索器簡介 [TP6.0 搜索器 官方文檔](http://www.hmoore.net/manual/thinkphp6_0/1037590) 用于封裝字段的查詢表達式,一個搜索器對應一個特殊的方法(該方法必須是public類型) >[danger] 搜索器應用場景 - 限制和規范表單的搜索條件 - 預定義查詢條件簡化查詢 ``` 其實就是用于封裝查詢條件表達式,最常見的是用于搜索數據、根據某個字段查詢數據 ``` >[danger] 模型搜索器定義規范 + 訪問類型:public + 方法名:searchFieldNameAttr + `FieldName`是數據表字段名的大駝峰命名轉換 >[danger] 框架源碼 ~~~php /** * 使用搜索器條件搜索字段 * @access public * @param array $fields 搜索字段 * @param array $data 搜索數據 * @param string $prefix 字段前綴標識 * @return $this */ public function withSearch(array $fields, array $data = [], string $prefix = '') { foreach ($fields as $key => $field) { if ($field instanceof Closure) { $field($this, $data[$key] ?? null, $data, $prefix); } elseif ($this->model) { // 檢測搜索器 $fieldName = is_numeric($key) ? $field : $key; $method = 'search' . Str::studly($fieldName) . 'Attr'; if (method_exists($this->model, $method)) { $this->model->$method($this, $data[$field] ?? null, $data, $prefix); } } } return $this; } ~~~ >[danger] 搜索器方法的參數 + $query:是一個對象,用于鏈接操作,不需要管他是什么值 + $value : 當前搜索器方法對應的字段值 + $data : withSearch()方法第二個參數的值 ``` // create_time 字段搜索器 時間范圍查詢 public function searchCreateTimeAttr($query, $value, $data) { // $query // $query是一個對象,用于實現鏈式操作 // // $value // 假設withSearch的第二參數為$arr // 則 $value = $arr['create_time'] // // $data // withSearch()方法第二個參數的值 $query->whereBetweenTime('create_time', $value[0], $value[1]); } ```
                  <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>

                              哎呀哎呀视频在线观看