我在我的codeigniter视图页面中添加了分页但我在我的sql查询中有了problam。在查询中我有IS NULL字 所以我想删除IS NULL字。
这是我的控制器功能
function category()
{
$this->load->model('news_model');
$this->load->model('get_db');
$cat = $this->uri->segment(2);
$cat_id = $cat;
$data['current_category']=$cat_id;
$config['per_page'] = 6;
$config['base_url'] = base_url().'category/'.$cat_id;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = 5;
$config['full_tag_open'] = '<ul>';
$config['full_tag_close'] = '</ul>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a>';
$config['cur_tag_close'] = '</a></li>';
$page = $this->uri->segment(3);
$data['page_no']=$page;
$limit_end = ($page * $config['per_page']) - $config['per_page'];
if ($limit_end < 0){
$limit_end = 0;
}
$data['count_news']= $this->news_model->count_news($cat_id);
$data['news'] = $this->news_model->viewnews($cat_id,$config['per_page'],$limit_end);
$config['total_rows'] = $data['count_news'];
$this->pagination->initialize($config);
$data['random_post'] = $this->news_model->get_randompost();
$data['footer_recent'] = $this->news_model->get_footer_recent();
$data['category'] = $this->get_db->get_category();
$this->load->view('header',$data);
$this->load->view('category',$data);
$this->load->view('footer');
}
这是我的模特功能
function viewnews($id,$limit_start=null,$limit_end=null)
{
$this->db->select('*');
$this->db->from('add_news');
$where = "FIND_IN_SET($id,type)";
$this->db->where($where);
$this->db->order_by('id','DESC');
if($limit_start && $limit_end){
$this->db->limit($limit_start, $limit_end);
}
if($limit_start != null){
$this->db->limit($limit_start, $limit_end);
}
$query = $this->db->get();
print_r($this->db->last_query());
die;
return $query->result_array();
}
然后我有了这个查询
SELECT * FROM (`add_news`) WHERE FIND_IN_SET(4,type) IS NULL ORDER BY `id` DESC LIMIT 6
请删除IS NULL字
请帮助......