标签:style blog io ar color sp on div art
1 <?php 2 class CommonModel extends CI_Model{ 3 function __construct(){ 4 parent::__construct(); 5 $this->load->database(); 6 } 7 public function search($table,$where){ 8 $this->db->where($where); 9 $query=$this->db->get($table); 10 return $query->result_array(); 11 } 12 public function pageGet($table,$where=null,$start=1,$limit=10){ 13 $result=$this->db->get($table)->result_array(); 14 return $result; 15 } 16 public function findOne($table,$idmap){ 17 $this->db->where($idmap[‘key‘],$idmap[‘value‘]); 18 $this->db->select(‘*‘); 19 $query=$this->db->get($table); 20 $one=$query->row_array(); 21 return $one; 22 } 23 24 public function addData($table,$data){ 25 return $this->db->insert($table,$data); 26 } 27 28 public function modify($table,$data,$where){ 29 $this->db->where($where); 30 return $this->db->update($table,$data); 31 } 32 33 public function remove($idmap,$table){ 34 if(is_array($idmap[‘value‘])){ 35 $ids=implode($id, ‘,‘); 36 $this->db->where($idmap[‘key‘].‘ in‘,‘(‘.$idmap[‘value‘].‘)‘); 37 $this->db->delete($table,array($idmap[‘key‘].‘ in‘,‘(‘.$idmap[‘value‘].‘)‘)); 38 }else{ 39 $this->db->delete($table,array($idmap[‘key‘],$idmap[‘value‘])); 40 } 41 } 42 }
标签:style blog io ar color sp on div art
原文地址:http://www.cnblogs.com/codetown/p/4133952.html