<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Provincecity_app_model extends CI_Model{
private $table='provincecity'; public function check($where){
if (!is_array($where)){
return false;
}
$this->db->where($where);
$res=$this->db->get($this->table)->result_array();
return $res;
}
public function check_all(){
$res=$this->db->order_by('displayOrder','asc')->get($this->table)->result_array();
return $res;
}
public function show_home(){ $this->db->where('show_home',1);
$res=$this->db->get($this->table,8)->result_array();
return $res;
}
public function comment(){ $this->db->where('comment_show',1);
$res=$this->db->get($this->table)->result_array();
return $res;
}
public function update($id,$data){
$data['updatetime']=time();
$this->db->where('id',$id);
$this->db->update($this->table,$data);
$res=$this->db->affected_rows();
return $res;
}
public function add($data){
$data['createtime']=time();
$this->db->insert($this->table,$data);
$res=$this->db->insert_id();
return $res;
}
public function delete($id){
$this->db->where('id',$id)->delete($this->table);
$res=$this->db->affected_rows();
return $res;
}
public function page($start_position,$per_nums,$issue,$ser='',$city=''){
if(!empty($city)){ $this->db->where('city',$city);
}
if(!empty($ser)){
$this->db->like('content',$ser);
}
$this->db->where('issue',$issue);
$data['total_nums']=$this->db->get($this->table)->num_rows();
if(!empty($city)){
$this->db->where('city',$city);
}
if(!empty($ser)){
$this->db->like('content',$ser);
}
$this->db->where('issue',$issue);
$this->db->order_by('id','desc'); $res=$this->db->get($this->table,$per_nums,$start_position)->result_array();
$data[]=$res; return $data;
}
public function getHouseRow($houseId = 0)
{
$this->db->where('id', $houseId);
return $this->db->get($this->table)->row_array();
}
}
?>