<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之旅 廣告
                # 查詢數據庫 ### 數據集返回類型改為collection # 注意::所以的查詢如果數據庫沒有相關值返回null 空 ,有返回數據 ![](https://img.kancloud.cn/35/e3/35e3ef4fab5c89e65a04b98a8e9633ea_633x556.png) ## 查詢數據庫語法1: ## self::get(1)查詢數據庫其中(1)為ID1 找自增主鍵 ## toArray() 對象集轉換為數組 ## 代碼案例: ``` use think\Model; class Maik extends Model{ public function usenameinfo(){ $res=self::get(1); dump($res->toArray()); //對象集轉換為數組 } ``` ## 獲取多條數據 ``` self::all([1,3,4]) 其中1,3,4為數據庫主鍵,ID的值 <?php ``` ## 代碼案例: ``` namespace app\index\model; use think\Model; class Maik extends Model{ public function usenameinfo(){ $res=self::all([1,3,4]); dump($res->toArray()); } ``` ## get方法條件查詢法: ``` ## self::get(['name'=>'zhangxueyou']); // 其中name為數據庫鍵名,zhangxueyou為數據值, ``` ## 代碼案例: ``` <?php namespace app\index\model; //命名空間model use think\Model; //引入think里的 Model類 class Maik extends Model{ public function usenameinfo(){ //$res=self::get(['name'=>'liudehua']); //get方法條件查詢 $res=$this->select(); //查詢 Maik表里的所有數據 //dump($res->toArray()); dump($res->toArray()); //返回對象數組化 } } ``` ## find()方法查詢 ``` ## $res=$this->where('id',1)->find(); //where()條件查詢 ``` ## select()方法多條查詢 ``` $res=$this->select(); ``` ## select()方法單條查詢 ``` $res=$this->where('id',1)->select(); ``` ## 代碼案例: ``` <?php namespace app\index\model; use think\Model; class Maik extends Model{ public function usenameinfo(){ $res=$this->select(); dump($res->toArray()); } } ``` ## 調用方法: controller模型里調用 ![](https://img.kancloud.cn/01/9c/019c85f620b6e68cd16b12405b203b0f_788x671.png) ``` <?php namespace app\index\controller; use think\Controller; use think\Db; use app\index\model\Maik; use app\index\controller\Admin; class Index extends controller { public function index(){ $data=new Maik(); $data->usenameinfo(); } } ```
                  <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>

                              哎呀哎呀视频在线观看