Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller |
[eluser]Unknown[/eluser]
i've got this error when i tried to retrieve data from database and show it to my form_dropown() can anybody help me with this error?? this is some of my code : the controller : function register_emp() { $this->reg_model->get_sec('id','sec_name','sector'); $this->load->view('emp_reg_view', $data); } the model : function get_sec($id, $name, $from) { $result = array(); $result_key = $this->db->query('select '.$id.', '.$nama.' from '.$from.' order by '.$id.' asc'); foreach($result_key->result()as $row) { $result[$row->$id]= $row->$id .'-'. $name; } return $result; } the view : <?php echo form_dropdown('ind_sec', $nama, set_value('ind_sec', $id)); ?> thanx b4 rikes
[eluser]bl00dshooter[/eluser]
You need to load the model before using it. Code: $this->load->model('reg_model'); More info at http://ellislab.com/codeigniter/user-gui...odels.html. Also, this is by far not a bug. Please post only possible bug reports in this section. The help section can be found at: http://ellislab.com/forums/viewforum/127/.
[eluser]Unknown[/eluser]
im sorry, its like i paste the wrong code from my controller my controller is function register_emp() { $this->load->model('reg_model'); $data['get_sector'] = $this->reg_model->get_sec('id','sec_name','sector'); $this->load->view('emp_reg_view', $data); } i already load the model and i still got the error sorry twice, because im new here, i dont know if im in the wrong topic, can somebody tell me how to move this post to the right topic??? thanx btw
[eluser]WanWizard[/eluser]
The error message is "undefined method". So the problem isn't that the model class isn't loaded (that would have given an undefined property error), but that there's no (accessable) method in the model called 'get_sec'. |
Welcome Guest, Not a member yet? Register Sign In |