学习数据库操作位置
/mobileapp/xnjz/lib/db.php
增 $result = $this->db->insert(‘gongdi_jl’,$data);
$insertId = $this->db->get_insert_id();
单查$sq_id=$this->db->get_one(“select sq_id from to8to_gongdi_jl where yid=”.$data[‘yid’].” order by sq_id desc limit 1”);
多查$gongdis = $this->db->get_all(“select zid,chenghu,phone,addr,puttime,jltime from to8to_jj_smt_zb where yz_id=$uid and chuli=2 and yid>0 and uid>0 and zxbyh=1 and cputtime>$min_time”);
改 $this->db->update(“to8to_yewu_caiwu_zd”,array(“dk_hzd”=>$filename),”id=$insertId”);
例如 比如更新姓名为张三的用户为李四,年龄为21
- update(“users”, array(“user_name”=>”张三”, “user_age”=>”20岁”), “user_name=’张三’”)
删 delete($table, $where)
$this->wrap(array(),$data[‘title’],null,$data[‘status’]);
protected function wrap($data, $title = null,$totalPage = 0,$status=1)
{
if (isset($totalPage)) {
exit(json_encode(array(‘status’=>$status, ‘title’=>$title,’totalpage’=>$totalPage, ‘content’=>$data)));
}else{
exit(json_encode(array(‘status’=>$status, ‘title’=>$title,’content’=>$data)));
}
}