error in loading model in controller |
[eluser]praveena[/eluser]
hi I was trying to load the model in cotroller but its showing Fatal error: Call to undefined method modelname::insert() in E:\wamp\www\project\system\application\controllers\upload.php on line 213 pls help me its urgent regards Praveena
[eluser]Cristian Gilè[/eluser]
Please, provide the controller and the model code. We need more info to debug
[eluser]praveena[/eluser]
in controller function is present in the model I was trying to load in controller $this->load->model('modelname'); $ss=$this->modelname->insert($id);
[eluser]smilie[/eluser]
And again - please provide model and controller code... Cheers, Smilie
[eluser]praveena[/eluser]
My controller function load() { $this->load->model('modelname'); $ss=$this->modelname->insert($id); $msgs['msg'] = 'You have insertted a file successfully!'; $this->load->view('success', $msgs); } Model Code function insert($id) { $query=$this->db->query("select * from data_repy where file_id={$id}"); $ids=""; foreach($query->result_array() as $row) { $ids[]=$row; } return $ids; } *********************************************************************************************** regards Praveena
[eluser]smilie[/eluser]
Still a lot of code missing, but some hints: - is model in the 'models' directory? - is the name of the model: modelname.php? - is the class in the model: Modelname (which extends Model)? see: http://ellislab.com/codeigniter/user-gui...ml#anatomy Cheers, Smilie edit: typo;
[eluser]praveena[/eluser]
Model in the moidels directory no its just modelname class modelname extends Model{ function load() { $this->load->model(‘modelname’); $ss=$this->modelname->insert($id); $msgs[‘msg’] = ‘You have insertted a file successfully!’; $this->load->view(‘success’, $msgs); } }
[eluser]Cristian Gilè[/eluser]
Model class names must have the first letter capitalized! http://ellislab.com/codeigniter/user-gui...ml#anatomy
[eluser]smilie[/eluser]
Oke, read this again - carefully: http://ellislab.com/codeigniter/user-gui...ml#anatomy It says, class name must be capitalized first letter, so: class Modelname extens Model Cheers, Smilie
[eluser]praveena[/eluser]
I declared like this class Model_name extends Model{ but the same error continues Call to undefined method Model_name::insert() in E:\wamp\www\project\system\application\controllers\upload.php on pls help me Regards Praveena |
Welcome Guest, Not a member yet? Register Sign In |