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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 查詢構造器 現在主流框架的數據庫都包含鏈式操作方法,不過高手其實還是比較喜歡手寫sql的,并不依賴查詢類,所以要養成盡量手寫sql的習慣。 一般情況下只要最終沒有獲取到數據,一般函數的返回值都是`$this` [TOC] ### where條件相關 #### where條件 where條件最多可以接受4個參數 如果參數是一個,表示是一個完整的條件語句,不會進行預處理 例如: ~~~ Db::table('news')->where('id=1'); ~~~ 如果第一個參數一個數組則會循環調用where 例如: 多個where條件 ~~~ Db::table('news')->where([['id', 1], ['look_time', 2]]); ~~~ 如果參數是二個,第一個表示字段,第二個表示參數,會進行預處理 ~~~ Db::table('news')->where('id', 1); ~~~ 如果參數是三個,第一個表示字段,第二個表示邏輯`= > <`,第三個表示參數,會進行預處理 ~~~ Db::table('news')->where('id', '=', 1); ~~~ 如果參數是四個,第一個表示字段,第二個表示邏輯`= > <`,第三個表示參數,第四個表示邏輯`or and`多個where條件的邏輯 ~~~ Db::table('news')->where('id', '=', 1, 'and'); ~~~ #### whereIn ~~~ /** * where In in (1,2,3) * @param [type] $field [字段] * @param array $params [參數] * @param string $logic [與其它條件的邏輯 AND|OR] * @return [type] [description] */ public function whereIn($field, array $params, $logic = 'AND') Db::table('news')->whereIn('id',[1,2,3,4]); ~~~ #### whereNotIn ~~~ /** * where Not In * @param [type] $field [字段] * @param [type] $params [參數] * @param string $logic [與其它條件的邏輯] * @return [type] [description] */ public function whereNotIn($field, array $params, $logic = 'AND') Db::table('news')->whereNotIn('id',[1,2,3,4]); ~~~ #### whereBetween ~~~ /** * where id between * @param [type] $field [字段] * @param array $params [參數] * @param string $logic [與其它條件的邏輯] * @return [type] [description] */ public function whereBetween($field, array $params, $logic = 'AND') Db::table('news')->whereBetween('look_time', [10, 20]); ~~~ #### whereNotBetween ~~~ /** * where NotBetween * @param [type] $field [字段] * @param array $params [參數] * @param string $logic [與其它條件的邏輯] * @return [type] [description] */ public function whereNotBetween($field, array $params, $logic = 'AND') Db::table('news')->whereNotBetween('look_time', [10, 20]); ~~~ #### whereNull ~~~ /** * where null * @param [type] $field [字段] * @param string $logic [與其它條件的邏輯] * @return [type] [description] */ public function whereNull($field, $logic = 'AND') Db::table('news')->whereNull('description'); ~~~ #### whereNotNull ~~~ /** * where not null * @param [type] $field [字段] * @param string $logic [與其它條件的邏輯] * @return [type] [description] */ public function whereNotNull($field, $logic = 'AND') Db::table('news')->whereNotNull('description'); ~~~ ### 分組group ~~~ /** * 分組 * @param [type] $field [按照那個字段進行分組] * @return [type] [description] */ public function group($field) Db::table('news')->group('look_time'); ~~~ ### 排序 ~~~ /** * 排序 * @param [type] $field [排序字段] * @param [type] $type [排序方式 asc desc] * @return [type] [description] */ public function order($field, $type) Db::table('user')->whereIn('gid',[1,2,3,4,5])->order('login_time', 'asc'); ~~~ ### having查詢后篩選 ~~~ /** * 過濾 * @param [type] $field [字段] * @param array $params [參數] * @return [type] [description] */ public function having($field, array $params = []) Db::table('user')->whereIn('gid',[1,2,3,4,5])->group('login_time')->having('login_time>?', [3]); ~~~ ### limit獲取條數 ~~~ /** * 獲取條數 limit * @param [type] $limit [位置] * @return [type] [獲取條數] */ public function limit($start, $number = '') Db::table('user')->whereIn('gid',[1,2,3,4,5])->group('login_time')->having('login_time>?', [3])->limit(2,5); ~~~ ### 強制使用索引 ~~~ /** * 強制使用索引 * @param [type] $index [索引名稱] * @return [type] [description] */ public function force($index) ~~~ ### 事務鎖 ~~~ /** * 事務鎖 * @return [type] [description] */ public function lock() Db::table('news')->lock() ~~~ ### union查詢 ~~~ /** * [union 查詢] * @param [type] $sql [sql語句] * @param boolean $all [是否返回所以結果] * @return [type] [description] */ public function union($sql, $all = false) ~~~ ### 大數據分批處理 ~~~ /** * 查詢分批 * @param [type] $limit [每次處理個數] * @param [type] $func [處理方法閉包或者函數] * @return [type] [description] */ public function chunk($limit = 100, $func) ~~~ ### 游標處理 ~~~ /** * 游標 yield 生成器查詢 * @return [type] [description] */ public function cursor() 可以進行循環 ~~~ ### 獲得所有查詢sql ~~~ Db::getQuerySql(); ~~~ ### 表別名 ~~~ Db::table('news')->alias('n'); ~~~ ### 設置獲取字段 ~~~ /** * 獲取字段 * @param [type] $field [字段] * @return [type] [description] */ public function field($field) Db::table('news')->alias('n')->field('nid,title,description')->where('look_time>3)->select(); ~~~ ### distinct ~~~ public function distinct($s = true) ~~~ ### 設置數據 ~~~ /** * 設置數據 * @param array $data [description] * @return [type] [description] */ public function data(array $data) ~~~
                  <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>

                              哎呀哎呀视频在线观看