<?php

class Table{
         protected $tablename;
         protected $arrTable;
        protected $w='';//条件属性
        protected $field="*";//查询字段
        protected $order="";
         function __construct($arrTable=''){
               $this->tablename=get_class($this);//获取获取当前的对象名
                $this->arrTable=$arrTable;
         }
         function insert(){
                echo $this->insertTable();
             }
         private function insertTable(){
             $keys="(";
             $values="(";
             foreach ($this->arrTable as $key => $value) {
                $keys.=$key.",";
                $values.="'".$value."',";
             }
             $keys=substr($keys, 0,-1).")";
             $values=substr($values,0,-1).")";
             return  "insert {$this->tablename} {$keys} values {$values}<br>";
          }

function del(){
            if ($this->w!=''){//表示没有条件
               $delstr="delete from {$this->tablename} where {$this->w}";               
            }else{
               $delstr="delete from {$this->tablename}";
            }
            echo $delstr."<br>";

}
         function where($w=''){
            $this->w=$w;
         }
          function update(){
            $updateData="";
            foreach ($this->arrTable as $key => $value) {
                $updateData.=$key."=".$value.",";
            }
            $updateData=substr($updateData,0,-1);
            if ($this->w=="") {
               echo "update {$this->tablename} set {$updateData} <br>";
            }else{
               echo "update {$this->tablename} set {$updateData} where {$this->w}<br>";
            }
            
         }
          function select(){
            if ($this->w==""){
               $select="select {$this->field} from {$this->tablename} {$this->order}";  
            }else{
               $select="select {$this->field} from {$this->tablename} where {$this->w} {$this->order}";  
            }
            echo $select."<br>";

}
         //查询字段
         function field($field="*"){
            $this->field=$field;
         }
         //排序
         function order($order=''){
            $this->order=$order;
         }
   }
   /**
   *
   */
   class User extends Table
   {
         
       
   }
   /**
   *
   */
   class Article extends Table
   {
       
       
   }
   /**
   *
   */
   class Student extends Table
   {
      
     
   }
   $Datas=array("username"=>"admin","userpass"=>'admin');
   $user1=new User($Datas);
   $user1->insert();
   $Datas=array("title"=>"admin","author"=>'admin');
   $a=new Article($Datas);
   $a->insert();
   $a->where("title='清远'");
   $a->del();
   $a->update();
   $Datas = array('id' =>'001' ,'name'=>'zhangsan' );
   $s1=new Student($Datas);
   $s1->insert();
   $s1->field("title,author");
   $s1->select();

// $iswhere=""

?>

最新文章

  1. ubuntu16.04(beaglebone) 下vim 和gcc 的信息
  2. 关于 windows 下 node_modules\node-sass\vendor 的报错解决方法
  3. 定时器的应用---查询方式---让8个LED灯,左右各4个来回亮
  4. iOS ARC内存管理
  5. ASM文件系统
  6. AC自动机---Keywords Search
  7. String、StringBuilder、StringBuffer
  8. python学习day4--python基础--字典
  9. java中的进制转换方法
  10. switch语句:适用于一个条件有多个分支的情况---分支语句
  11. js模态窗口
  12. ubuntu12.04 残疾人游客
  13. openstack私有云布署实践【14.2 登录页dashboard-controller(办公网环境)】
  14. Redis安装及使用笔记
  15. JSON WEB TOKEN(JWT)的分析
  16. BZOJ1925 [Sdoi2010]地精部落 动态规划
  17. 【HttpClient】一个http_post请求例子
  18. Centos Raid0 与Raid1 的备注
  19. Scala 中的构造器
  20. EasyUi – 5.修改$.messager.show() 弹出窗口在浏览器顶部中间出现

热门文章

  1. HTTP 错误 500.19 - Internal Server Error 无法读取配置节 system.serviceModel 因为它缺少节声明
  2. vim 撤销 回退操作
  3. gitlab+jenkins+tomcat CI/CD 部署
  4. SQL语句精简版
  5. db2look 工具
  6. iOS 线程安全--锁
  7. 使用hashlib进行文件校验
  8. js篇-解析url链接里面的参数名和参数值
  9. mysql数据库字符集相关操作(修改表字段编码,使其支持emoji表情)
  10. Python Async/Await入门指南