CodeIgniter Forums
Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller (/showthread.php?tid=38058)



Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller - El Forum - 01-29-2011

[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


Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller - El Forum - 01-29-2011

[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-guide/general/models.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/.


Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller - El Forum - 01-29-2011

[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


Fatal error: Call to undefined method Reg_model::get_sec() in C:\xampp\htdocs\careercenter\system\application\controller - El Forum - 01-29-2011

[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'.