(Solved) how to load/call a function within a class? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: (Solved) how to load/call a function within a class? (/showthread.php?tid=36468) |
(Solved) how to load/call a function within a class? - El Forum - 12-02-2010 [eluser]Unknown[/eluser] In order to load a function in a controller from a model is easy but how do you call a function within a class in a controller? class Crud extends controller { function index () { ????? how to load a function get_all ????? } function get_all () { $mydata = $this->db->get('users'); foreach ($mydata->result() as $row) { $aa= $row->username; echo $aa; } } } (Solved) how to load/call a function within a class? - El Forum - 12-02-2010 [eluser]2think[/eluser] Using standard PHP convention: $this->get_all(); * Note: You said it's easy to load a function in a controller from a model but the conventional CI arrangement is to call a model's functions from a controller; hence the name - controller. (Solved) how to load/call a function within a class? - El Forum - 12-02-2010 [eluser]Unknown[/eluser] [quote author="2think" date="1291347328"]Using standard PHP convention: $this->get_all(); * Note: You said it's easy to load a function in a controller from a model but the conventional CI arrangement is to call a model's functions from a controller; hence the name - controller.[/quote] Thank you! (Solved) how to load/call a function within a class? - El Forum - 12-02-2010 [eluser]2think[/eluser] You're welcome and thank YOU for posting [solved] in the subject, its proper etiquette but I have even at times been more than guilty of not doing same. |