<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 功能強大 支持多語言、二開方便! 廣告
                # 時間查詢 ## 時間比較 ### 使用`where`方法 `where`方法支持時間比較,例如: ``` // 大于某個時間 where('create_time', '> time', '2016-1-1'); // 小于某個時間 where('create_time', '<= time', '2016-1-1'); // 時間區間查詢 where('create_time', 'between time', ['2015-1-1', '2016-1-1']); ``` 第三個參數可以傳入任何有效的時間表達式,會自動識別你的時間字段類型,支持的時間類型包括`timestamps`、`datetime`、`date`和`int`。 ### 使用`whereTime`方法 `whereTime`方法提供了日期和時間字段的快捷查詢,示例如下: ``` // 大于某個時間 Db::name('user') ->whereTime('birthday', '>=', '1970-10-1') ->select(); // 小于某個時間 Db::name('user') ->whereTime('birthday', '<', '2000-10-1') ->select(); // 時間區間查詢 Db::name('user') ->whereTime('birthday', 'between', ['1970-10-1', '2000-10-1']) ->select(); // 不在某個時間區間 Db::name('user') ->whereTime('birthday', 'not between', ['1970-10-1', '2000-10-1']) ->select(); ``` 針對時間的區間查詢,系統還提供了一個`whereBetweenTime`快速方法 ``` // 查詢2017年上半年注冊的用戶 Db::name('user') ->whereBetweenTime('create_time', '2017-01-01', '2017-06-30') ->select(); // 查詢2017年6月1日注冊的用戶 Db::name('user') ->whereBetweenTime('create_time', '2017-06-01') ->select(); ``` 沒有指定結束時間的話,表示查詢當天。 ## 時間表達式 還提供了更方便的時間表達式查詢,例如: ``` // 獲取今天的博客 Db::name('blog') ->whereTime('create_time', 'today') ->select(); // 獲取昨天的博客 Db::name('blog') ->whereTime('create_time', 'yesterday') ->select(); // 獲取本周的博客 Db::name('blog') ->whereTime('create_time', 'week') ->select(); // 獲取上周的博客 Db::name('blog') ->whereTime('create_time', 'last week') ->select(); // 獲取本月的博客 Db::name('blog') ->whereTime('create_time', 'month') ->select(); // 獲取上月的博客 Db::name('blog') ->whereTime('create_time', 'last month') ->select(); // 獲取今年的博客 Db::name('blog') ->whereTime('create_time', 'year') ->select(); // 獲取去年的博客 Db::name('blog') ->whereTime('create_time', 'last year') ->select(); ``` 如果查詢當天、本周、本月和今年的時間,還可以簡化為: ``` // 獲取今天的博客 Db::name('blog') ->whereTime('create_time', 'd') ->select(); // 獲取本周的博客 Db::name('blog') ->whereTime('create_time', 'w') ->select(); // 獲取本月的博客 Db::name('blog') ->whereTime('create_time', 'm') ->select(); // 獲取今年的博客 Db::name('blog') ->whereTime('create_time', 'y') ->select(); ``` 還可以使用下面的時間表達式進行時間查詢 ``` // 查詢兩個小時內的博客 Db::name('blog') ->whereTime('create_time','-2 hours') ->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>

                              哎呀哎呀视频在线观看