MySql 常用语句
增加数据 $sql = "insert into 数据表(列表字段) values('值列表')"; 删除数据 $sql = "delete from 数据表 where id='1'";//删除id=1的数据 修改数据 $sql="update 数据表 set 字段1='修改1',字段2='修改2',字段3='修3' where id='1'"; $result = mysqli_query($conn,$sql);//处理数据库 查寻数据 ORDER BY (字段) DESC(倒序,ASC正序(默认)) limit 1 查询几条数据(0,4)查询0-4的数据) $sql = "select 字段值(*) from 数据表 where id='1'";//查询id=1的数据 $result = mysqli_query($sql); //处理sql语句 while($row = mysqli_fetch_array($result){ echo $row['字段值']; echo $row['字段值']; echo $row['字段值']; }
数据拼接 添加数据:
//拼接一维数提添加SQL $dataLogs = array( "staff_id" => 4, //发起ID "type" => 1, //报单类型 "auther" => 0, //0主管上级1转交部门2指定审核人 "work_id" => 5, //工作流ID "sort" => 9, //排序 "title" => "实例", "status" => 0, //审核 0未审核 1已审核 ); $data=array(); foreach ($dataLogs as $key =>$val) { $data[] = " $key = '".$val."'"; } $sql = "INSERT INTO ".get_table("workflow_logs")." SET ".implode(",",$data); print_r($sql )
$page = ($input['page'] - 1) * $input['limit'];
$sql = "SELECT * FROM `表` where {$where} ORDER BY `createtime` DESC LIMIT {$page}, {$input['limit']}");