Welcome Guest, Not a member yet? Register   Sign In
Confusion calling model functions
#11

[eluser]JulianM[/eluser]
I'd recommend you to respect the CodeIgniter guidelines and everything will work perfectly.

For example, models should be named as Post_model instead of Post. Controller name should be different than the Model name to avoid conflicts.

Then, in the controller you load the model using:

Code:
$this->load->model('post_model');

And later, you use that model in the controller as shown here:

Code:
$this->post_model->method($param1, $param2);

Good luck.


[quote author="Broxi" date="1246108384"]Hi everyone,

I need some help as I am getting a bit confussed. I have a controller class called Posts and a model class names Posts.

If I try to access the model functions with:
Code:
$this->Post->getAll();
I get an Undefined property: Posts::$Post error, but if I use:
Code:
Post::getAll();
It works fine.

Firstly is it ok to call models like that and if not, any idea why I get the error.

Many thanks
Broxi[/quote]


Messages In This Thread
Confusion calling model functions - by El Forum - 06-27-2009, 02:13 AM
Confusion calling model functions - by El Forum - 06-27-2009, 02:29 AM
Confusion calling model functions - by El Forum - 06-27-2009, 03:23 AM
Confusion calling model functions - by El Forum - 06-27-2009, 05:12 AM
Confusion calling model functions - by El Forum - 06-27-2009, 01:09 PM
Confusion calling model functions - by El Forum - 06-27-2009, 02:15 PM
Confusion calling model functions - by El Forum - 06-27-2009, 02:40 PM
Confusion calling model functions - by El Forum - 06-27-2009, 02:48 PM
Confusion calling model functions - by El Forum - 06-27-2009, 02:52 PM
Confusion calling model functions - by El Forum - 06-27-2009, 03:06 PM
Confusion calling model functions - by El Forum - 06-27-2009, 03:41 PM
Confusion calling model functions - by El Forum - 06-27-2009, 04:07 PM
Confusion calling model functions - by El Forum - 06-27-2009, 04:58 PM
Confusion calling model functions - by El Forum - 06-27-2009, 05:23 PM
Confusion calling model functions - by El Forum - 06-27-2009, 05:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB