![]() |
Constructor Help - 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: Constructor Help (/showthread.php?tid=39432) |
Constructor Help - El Forum - 03-10-2011 [eluser]bunoire14[/eluser] Hi Guys, hope this is the right place to post, I have an issue when trying to load a model from within the class constructor, it doesn't throw any errors but just gives me a blank page. Am i doing something incorrectly? Code: function __construct() Any help greatly appreciated! Constructor Help - El Forum - 03-10-2011 [eluser]danmontgomery[/eluser] Have you checked the apache error log for PHP errors? Constructor Help - El Forum - 03-10-2011 [eluser]fesweb[/eluser] You need to get the CodeIgniter super-object first... Code: function __construct() From the user guide: Quote:Note: You'll notice that the above get_instance() function is being passed by reference: Constructor Help - El Forum - 03-10-2011 [eluser]InsiteFX[/eluser] If he is loading the model from the controller he doe's not need to use the CI Superobject! If he trying to load it in a library etc then yes he will need the CI Superobject. InsiteFX Constructor Help - El Forum - 03-10-2011 [eluser]fesweb[/eluser] InsiteFX: Right - I missed that part since he was loading another model...oops... Constructor Help - El Forum - 03-10-2011 [eluser]joakley77[/eluser] Have you already checked to make sure you named the model correctly? I've been known to forget to correctly name the model controller before. IE [code] <?php // application/models/user_model.php class User_model extends CI_Model { // constructor/methods/etc } ?> Constructor Help - El Forum - 03-10-2011 [eluser]InsiteFX[/eluser] Here is a tip for all new users: Code: // use this at the top of all your controllers libraries and models. InsiteFX |