|
错误:Fatal error: Unsupported operand types in E:******\system\libraries\Pagination.php on line 112
控制器:
function times()
{
//查询字段的条件
if($this->input->post("timeok"))
{
$time1 = strtotime($this->input->post("time1"));
$time2 = strtotime($this->input->post("time2"));
//查询的表名
$table = 'shop';
if(!$this->sm->gettable($table))
{
return $this->sm->gettable($table);
}
$city_list = $this->sm->gettable($table);
$limit = 20;
//分页链接
$url = site_url('admin/shop/times'.'/'.$time1.'/'.$time2);
$this->load->library('pagination');
$config['base_url'] = $url;
$config['total_rows'] = $this->sm->time_count_lists($table,$time1,$time2);
$config['per_page'] = $limit;
$config['uri_segment'] = 5;
$config['last_link'] = '尾页';
$config['first_link'] = '首页';
$config['prev_link'] = '上页';
$config['next_link'] = '下页';
$this->pagination->initialize($config);
$page = $this->pagination->create_links();
$result = $this->sm->get_time($table,$time1,$time2,$limit,$offset);
$viewdata["result"] = $result;
$viewdata["page"] = $page;
$viewdata["city_list"] = $city_list;
$this->load->view('admin/shop/index',$viewdata);
}
模型:
function time_count_lists($table,$time1,$time2)
{
$query ="SELECT count( * ) FROM `c_shop` WHERE `addtime` BETWEEN $time1 AND $time2";
$rs =$this->db->query($query);
//echo $this->db->last_query();exit;
if($rs->num_rows()>0) {
$result = $rs->result_array();
}
return $result;
}
function gettable($gettable)
{
$result = array();
$query = "select distinct city from c_shop where provname ='**'";
$rs =$this->db->query($query);
if($rs->num_rows()>0) {
$result = $rs->result_array();
}
return $result;
}
function get_time($table,$time1,$time2,$limit,$offset=0)
{
$result = array();
$query ="SELECT * FROM `c_shop` WHERE `addtime` BETWEEN $time1 AND $time2 LIMIT $offset ,$limit";
$rs =$this->db->query($query);
echo $this->db->last_query();exit;
if($rs->num_rows()>0) {
$result = $rs->result_array();
}
return $result;
//echo $this->db->last_query();exit;
}
视图:
<form method="post" action="<?=site_url("admin/shop/times");?>" enctype="multipart/form-data">
<input type="text" name="time1" />-----<input type="text" name="time2" />
<input name="timeok" id="timeok" type="submit" value="选好了" />
</form>
|
|