php接続データベースクイック操作モジュール

4234 ワード

phplogic
1.2018.06.09     , phplogic            mysql       ,                ,          ,      ,  json    。
  :
    1.      ,            ,        php   ,     ,        
    2.    ,               ,           ,             sql  
    3.    sql  ,           ,      
    4.          ,    ,sql       ,  sql  ,           
    :

      {
          "code":0,
          "sql":"select id,title,explains,cover,time from sc_news order by time desc limit 0 , 4",
          "list":[
              {
                  "id":"97",
                  "title":"         ?          ?",
                  "explains":"         ?",
                  "cover":"http://121.43.37.189/tmAdmin/uploads/newsCover/20180516/182806138.jpg",
                  "time":"2018-05-16 18:28:06"
              }
          ],
          "allCount":30,
          "count":4,
          "msg":"success"
      }
      
      code  0       、    ,    ,       
            2            ,sql    
            3        
      sql          sql
      list             
      allCount              ,    ,       
      count             
      msg           
    : 
    4.1   
      include 'db/logic.php';
    4.2    :
      $fun = new logic();
    4.3  :
              insert("  ",“    ”)
            inserts("  ",“    ”)
              select(“  【   】”,“    【  】”,“   【  、   】”,“    ,     ”,“        ,      ,         ”);
              update("  ","       ","    ");
              delete("  ",“   ”);
      4.3.0      (     array  )
      echo json_encode($fun->select("tr_company",array('id','name','s_option'),$obj,""));
      4.3.1     (key=     value=   )
      $obj = array();
      $obj["uid"] = $_POST["uid"];
      $obj["name"] = $_POST["name"];
      $obj["input_time"] = date("Y-m-d H:i:s",time());
      $obj["state"] = 0;
      //        json
      echo json_encode($fun->insert("tr_purchase",$obj));
      4.3.2   
        $obj = array();
        $obj["template"] = $_POST['template'];
        $obj["name"] = $_POST['name'];
        $company = $fun->select("tr_company","",$obj,"");
        echo json_encode(company);
        //      page          row     
         $sort["page"] = $_POST["page"];
         $sort["row"] = 8; 
         //      orderbydesc                  orderby     
         $sort["orderbydesc"] = "upload_time";
         $company = $fun->select("tr_company","",$obj,$sort);
         echo json_encode(company);
         //    
         $obj["like_word"] = "   ";
         $obj["like_word_value"] = "'%".$_POST["   "]."%'";
         $fun->select("tr_company","",$obj,"");
         //    ,      (           )【                ,    n 】
         $id[] = 1;
         $id[] = 2;
         $id[] = 3;
         $id[] = 4;
         $obj["id"] = $id;
         $fun->select("tr_company","",$obj,"");
         //        【     >   <   != 】
          $obj = array();
          $obj["user_id"] =  $_POST["uid"];
          $obj["s_option !="] =  2;
          echo json_encode($fun->select("tr_company",array( 'name','s_option'),$obj,""));
       4.3.3     
          $obj["name"] = $_POST["name"];
          $c["id"] = $_POST["historyId"];
          echo json_encode($fun->update("tr_service",$obj,$c));
          //     (       ,        )
          $obj["id"] = $_POST["h_id"];
          $change = "page_view = page_view + 1 ";
          $res = $db->update($oe_content,$change,$obj);
       4.3.4      
          $objs["id"] = $_POST["c_id"]; 
$ren = $db->delete($oe_collect,$obj); github:https://github.com/zhuruicheng/logic