CodeIgniter Forums
Getting an invalid model function error when the function is declared. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Getting an invalid model function error when the function is declared. (/showthread.php?tid=8622)



Getting an invalid model function error when the function is declared. - El Forum - 05-24-2008

[eluser]doors[/eluser]
I have a crud model for my menu system.

When I load the model and try to execute three particular functions that are declared in the model I get php error stating that the model function is not declared.

The error is as follows:

Fatal error: Call to undefined method Main_model::edit_menu() ...


Can anyone tell me what is going on?


Getting an invalid model function error when the function is declared. - El Forum - 05-24-2008

[eluser]Michael Wales[/eluser]
Not without seeing some code.


Getting an invalid model function error when the function is declared. - El Forum - 05-25-2008

[eluser]bradym[/eluser]
You probably want to use

Code:
$this->edit_menu();

instead of

Code:
Main_model::edit_menu();

Take a look at http://www.php.net/manual/en/keyword.paamayim-nekudotayim.php (PHP 4) or http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php (PHP 5).


Getting an invalid model function error when the function is declared. - El Forum - 05-26-2008

[eluser]doors[/eluser]
[quote author="bradym" date="1211768153"]You probably want to use

Code:
$this->edit_menu();

instead of

Code:
Main_model::edit_menu();
[/quote]

I am actually using $this->main_model->edit_menu() to access the edit_menu() function within the Main_model class model.


Getting an invalid model function error when the function is declared. - El Forum - 05-26-2008

[eluser]bradym[/eluser]
Then, as Michael said, we'll need to see some code to help you.