CodeIgniter Forums
How to Use a method of a model in the same model Class - 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: How to Use a method of a model in the same model Class (/showthread.php?tid=24292)



How to Use a method of a model in the same model Class - El Forum - 11-05-2009

[eluser]davidino86[/eluser]
Hi to everybody,


can i and how use a function (method) of a model class in anoter method of the same model?

ex:

Code:
class mymodel extends Model

function mymodel()
{
   parent::Model();
}

fucntion firtMethod()
{
   //Call the second method
   $this->secondMethod($realVar);
}

function secondMethod($var)
{
  fetch something;
  retutn result;

}



How to Use a method of a model in the same model Class - El Forum - 11-05-2009

[eluser]davidino86[/eluser]
i got!

i'm sorry, i need to put the echo before the function

like this:

Code:
echo this->secondMethod($realVar);



How to Use a method of a model in the same model Class - El Forum - 11-05-2009

[eluser]Phil Sturgeon[/eluser]
Yeah that works fine. Did you try before you posted?


How to Use a method of a model in the same model Class - El Forum - 11-05-2009

[eluser]davidino86[/eluser]
no i'm sorry.

i think that if i write return is not necessary to put echo