Welcome Guest, Not a member yet? Register   Sign In
error in loading model in controller
#1

[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
#2

[eluser]Cristian Gilè[/eluser]
Please, provide the controller and the model code. We need more info to debug Wink
#3

[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);
#4

[eluser]smilie[/eluser]
And again - please provide model and controller code...

Cheers,
Smilie
#5

[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
#6

[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;
#7

[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);
}
}
#8

[eluser]Cristian Gilè[/eluser]
Model class names must have the first letter capitalized!

http://ellislab.com/codeigniter/user-gui...ml#anatomy
#9

[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
#10

[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




Theme © iAndrew 2016 - Forum software by © MyBB