![]() |
Confusion regarding variables in a Model - 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: Confusion regarding variables in a Model (/showthread.php?tid=41500) |
Confusion regarding variables in a Model - El Forum - 05-09-2011 [eluser]Unknown[/eluser] Hi All, I am a bit confused with using variables in a Model. If you see this page: http://ellislab.com/codeigniter/user-guide/general/models.html#what the function get_last_ten_entries() uses $query while other functions use $this->title, $this->content etc. I am assuming they are referenced using $this->variablename because those variables are private to this Model class and each of them will be initialized separately for separate functions. In other words $this->title in insert_entry() will be a different variable from $this->title in update_entry(). Just wanted to confirm if I am thinking right or not. Thanks. Confusion regarding variables in a Model - El Forum - 05-09-2011 [eluser]Nick_MyShuitings[/eluser] Correct, they are just defining the names above for clarity in reading the model. As you see in each method they are overriding the variable's value. Confusion regarding variables in a Model - El Forum - 05-10-2011 [eluser]danmontgomery[/eluser] http://www.php.net/manual/en/language.oop5.basic.php |