Unknown column in where clause in codeigniter query
<p>I have a codeigniter project. I have some dropdowns where i can select campus, session, class, group. I want filter data according to these dropdown values. Here is the function i call-</p>

<pre><code>function student_feeConfig()
    {
        if ($this-&gt;session-&gt;userdata('admin_login') != 1)
            redirect(base_url(), 'refresh');

            $campus_id = -1;
            $session_id = -1;
            $class_id = -1;
            $group_id = -1;
            if($this-&gt;input-&gt;post('campus_id') !=null)
                $campus_id = $this-&gt;input-&gt;post('campus_id');
                if($this-&gt;input-&gt;post('session_id') !=null)
                    $session_id = $this-&gt;input-&gt;post('session_id');
                    if($this-&gt;input-&gt;post('class_id') !=null)
                        $class_id = $this-&gt;input-&gt;post('class_id');

                        if($this-&gt;input-&gt;post('group_id') !=null)
                            $group_id = $this-&gt;input-&gt;post('group_id');
                            if($this-&gt;input-&gt;post('section_id') !=null)
                                $section_id = $this-&gt;input-&gt;post('section_id');

                                $campus = $this-&gt;db-&gt;get('campus')-&gt;result_array();         
                                $page_data['campus'] = array(''=&gt;'Select one');
                                foreach($campus as $row):
                                $page_data['campus'][$row['id']] = $row['campus_name'];
                                endforeach;
                                $page_data['id'] = $campus_id;

                                $session = $this-&gt;db-&gt;get('session')-&gt;result_array();
                                $page_data['sessions'] = array(''=&gt;'Select one');
                                foreach($session as $row):
                                $page_data['sessions'][$row['id']] = $row['uniqueCode'];
                                endforeach;
                                $page_data['session_id'] = $session_id;

                                $classinfo = $this-&gt;db-&gt;get_where('class', array('campus_id' =&gt; $campus_id))-&gt;result_array();                                       
                                $page_data['classes'] = array(''=&gt;'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-&gt;db-&gt;get_where('class_group', array('class_id' =&gt; $class_id))-&gt;result_array();
                                $page_data['groups'] = array(''=&gt;'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-&gt;db-&gt;select('enroll.group_id, student_feeConfig.*');
                                    $this-&gt;db-&gt;from('enroll');
                                    $this-&gt;db-&gt;join('student_feeConfig', 'enroll.student_id = student_feeConfig.student_id');
                                    $this-&gt;db-&gt;where('enroll.class_id', $class_id);
                                    $feeInfo = $this-&gt;db-&gt;get()-&gt;result_array();    
                                    $page_data['feeInfo'] = $feeInfo;
                                }


            $page_data['page_name']  = 'student_feeconf';
            $page_data['page_title'] = get_phrase('fee_management');
            $this-&gt;load-&gt;view('backend/index', $page_data);
    }
</code></pre>

<p>But i get error:</p>

<pre><code>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
</code></pre>