久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      關(guān)于thinkphp6.0.2實(shí)現(xiàn)對數(shù)據(jù)庫操作

      下面由thinkphp框架教程欄目給大家介紹thinkphp6.0.2實(shí)現(xiàn)對數(shù)據(jù)庫操作的方法,希望對需要的朋友有所幫助!

      關(guān)于thinkphp6.0.2實(shí)現(xiàn)對數(shù)據(jù)庫操作

      因?yàn)榘姹靖聦?dǎo)致有些沒入門的同學(xué)學(xué)習(xí)thinkphp6出現(xiàn)問題,在這里保留我學(xué)習(xí)的一點(diǎn)經(jīng)驗(yàn)!

      這是app/contrlar/目錄下新建的文件DbTest

      <?php
      namespace appcontroller;//要讓其控制器顯示
      use thinkfacadeDb;//使用哪個基類要包含其路徑

      class DbTest
      {
      public function demo1()
      {
      //原生查詢的讀操作query()
      $sql=“SELECT user_id,name,age,email FROM user WHERE age>:age LIMIT :num”;
      $map=array(“age”=>20,‘num’=>3);

      a=Db::query(a=Db::query(

      sql,

      map);dump(map); dump(

      a);
      }
      public function demo2()
      {
      //原生查詢的寫操作execute()
      $sql=“UPDATE user SET age=:age WHERE user_id=:id”;
      $map=array(“age”=>20,‘id’=>3);

      a=Db::execute(a=Db::execute(

      sql,

      map);return.map); return '成功更新了'.

      a.‘條數(shù)據(jù)!’;
      }
      //查詢構(gòu)造器
      //table()設(shè)置數(shù)據(jù)表
      //field()設(shè)置查詢字段列表
      //select()返回滿足條件的多條記錄
      //find()返回滿足條件的第一條參數(shù)
      public function demo3()
      {

      res=Db::table(user)?>field("userid,name,age")?>find(2);dump(res=Db::table('user') ->field("user_id,name,age") ->find(2); dump(

      res);
      }
      //where()設(shè)置查詢條件,參數(shù)包括字符串,表達(dá)式,數(shù)組
      //fetchsql():true,false
      public function demo4()
      {

      res=Db::table(user)?>field("userid,name,age")//?>where(userid=3)//?>where(userid,=,1)達(dá)//?>where(age,>,20)//?>where(age,between,[20,30])區(qū)//?>where([userid=>2,age=>20])數(shù)?>where([[age,between,[20,30]]])//數(shù)?>select();dump(res=Db::table('user') ->field("user_id,name,age") //->where('user_id=3')字符串 //->where('user_id','=','1')表達(dá)式 //->where('age','>','20') //->where('age','between',[20,30])區(qū)間查詢 //->where(['user_id'=>2,'age'=>20])數(shù)組查詢 ->where([['age','between',[20,30]]])//索引數(shù)組查詢 ->select(); dump(

      res);
      }?>

      比起以往版本這個無需設(shè)置路由,數(shù)據(jù)庫也有原生文檔Env可以修改,想要添加新文檔首先在config/app.php里面將應(yīng)用變量指向你的新文檔然后打開瀏覽器輸入:

      服務(wù)器名/類名/函數(shù)名/

      即可訪問了

      關(guān)于thinkphp6.0.2實(shí)現(xiàn)對數(shù)據(jù)庫操作

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號