<?php //controller
function notif()
{
$condition = $this->business_model->get_condition();
$this->data['query'] = $this->business_model->data_pagination_admin($condition);
$this->load->view('student_result',$this->data);
}
?>
<?php //model
function get_condition()
{
$this->db->select('condition');
$this->db->from('staff');
$query = $this->db->get();
return $query->result_array();
}
function data_pagination_admin($condition)//notif function
{
//...........
$this->db->where('flag','n');
//$user_id = $this->session->userdata('condition');
$this->db->where($condition,$user);//notice parameter condition
$this->db->order_by('next_date','asc');
$query = $this->db->get('student',10,0);
return $query->result_array();
}
/*im getting error :"Unknown column '0' in 'where clause'
SELECT * FROM (`student`) JOIN `status_table` ON `student`.`stud_id` =
`status_table`.`stud_id` WHERE `status_table`.`next_date` > '2013-06-09 23:59:59'
AND `flag` = 'n' AND **`0` = Array ORDER** BY `next_date` asc LIMIT 10"*/
?>
1.im 从模型获取值到控制器并将其传递给控制器到另一个函数,但出现错误。
2.controller->get_condition->controller->data_pagination_admin()
3.get 条件函数将只返回一个字符串,仅此而已