我有一个codeigniter项目。我有一些下拉菜单,我可以选择校园,课程,班级,小组。我想根据这些下拉值来过滤数据。这是我打电话的功能 -
function student_feeConfig()
{
if ($this->session->userdata('admin_login') != 1)
redirect(base_url(), 'refresh');
$campus_id = -1;
$session_id = -1;
$class_id = -1;
$group_id = -1;
if($this->input->post('campus_id') !=null)
$campus_id = $this->input->post('campus_id');
if($this->input->post('session_id') !=null)
$session_id = $this->input->post('session_id');
if($this->input->post('class_id') !=null)
$class_id = $this->input->post('class_id');
if($this->input->post('group_id') !=null)
$group_id = $this->input->post('group_id');
if($this->input->post('section_id') !=null)
$section_id = $this->input->post('section_id');
$campus = $this->db->get('campus')->result_array();
$page_data['campus'] = array(''=>'Select one');
foreach($campus as $row):
$page_data['campus'][$row['id']] = $row['campus_name'];
endforeach;
$page_data['id'] = $campus_id;
$session = $this->db->get('session')->result_array();
$page_data['sessions'] = array(''=>'Select one');
foreach($session as $row):
$page_data['sessions'][$row['id']] = $row['uniqueCode'];
endforeach;
$page_data['session_id'] = $session_id;
$classinfo = $this->db->get_where('class', array('campus_id' => $campus_id))->result_array();
$page_data['classes'] = array(''=>'Select one');
foreach($classinfo as $row):
$page_data['classes'][$row['class_id']] = $row['name'];
endforeach;
$page_data['allclass']=$page_data['classes'];
$page_data['class_id'] = $class_id;
$groups = $this->db->get_where('class_group', array('class_id' => $class_id))->result_array();
$page_data['groups'] = array(''=>'Select one');
foreach($groups as $row):
$page_data['groups'][$row['id']] = $row['group_name'];
endforeach;
$page_data['group_id'] = $group_id;
if($class_id != -1) {
$this->db->select('enroll.group_id, student_feeConfig.*');
$this->db->from('enroll');
$this->db->join('student_feeConfig', 'enroll.student_id = student_feeConfig.student_id');
$this->db->where('enroll.class_id', $class_id);
$feeInfo = $this->db->get()->result_array();
$page_data['feeInfo'] = $feeInfo;
}
$page_data['page_name'] = 'student_feeconf';
$page_data['page_title'] = get_phrase('fee_management');
$this->load->view('backend/index', $page_data);
}
但我得到错误:
Error Number: 1054
Unknown column 'enroll.class_id' in 'where clause'
UPDATE `ci_sessions` SET `timestamp` = 1478060781 WHERE `enroll`.`class_id` = '4' AND `id` = 'a351278bf35ab714c6f3de3479627cb5c009c7a6'
Filename: libraries/Session/drivers/Session_database_driver.php
Line Number: 243
答案 0 :(得分:2)
您的代码是:
if($class_id != -1) {
$this->db->select('enroll.group_id, student_feeConfig.*');
$this->db->from('enroll');
$this->db->join('student_feeConfig', 'enroll.student_id = student_feeConfig.student_id');
$this->db->where('enroll.class_id', $class_id);
$feeInfo = $this->db->ge()->result_array();
$page_data['feeInfo'] = $feeInfo;
}
你正在使用->db->ge()
这样的
$feeInfo = $this->db->ge()->result_array();
更正如下:
$feeInfo = $this->db->get()->result_array();
并在enroll.class_id
条件之后添加if($class_id != -1) {
如下:
$this->db->select('enroll.group_id, enroll.class_id, student_feeConfig.*');