<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之旅 廣告
                # 1.Laravel Eloquent模型 Eloquent 返回的所有結果集都是 Illuminate\Database\Eloquent\Collection 對象的實例,包括通過 get 方法檢索或通過訪問關聯關系獲取到的結果。 Eloquent 的集合對象繼承了 Laravel 的 Base Collection,因此它自然也繼承了數十種能優雅地處理 Eloquent 模型底層數組的方法。因此要判斷數據存在,直接用內置方法即可。 ## // 1.使用內置方法 isEmpty() ``` $userItems = User::where('sex', '=', '1')->get(); if ($userItems->isEmpty()) { } ``` ## // 2.使用內置方法 count() 檢查有沒有記錄 ``` if (User::where('email', '=', $email)->count() > 0) { // 有記錄 } ``` ## // 3.使用內置方法 exists() 建議使用該方法 ``` $userItems = User::where('sex', '=', '1')->get(); if ($userItems->exists()) { // 有記錄 } ``` ## // 4.使用內置方法 first() ``` $user = User::where('email', '=', $email)->first(); if ($user === null) { // 沒記錄 } ``` # 2.數據庫:查詢構造器 直接使用is_null()或empty()判段結果集是否為空。 ``` $users = DB::table('users')->where('id', $id)->get(); ``` ## // 方法1 ``` if($users){ // 有記錄 } ``` ## // 方法2 ``` if(is_null($users)){ // 沒記錄 } ``` ## // 方法3 ## ``` if(empty($users)){ // 沒記錄 } ```
                  <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>

                              哎呀哎呀视频在线观看