CodeIgniter Forums
loading model return value?? - 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: loading model return value?? (/showthread.php?tid=6670)



loading model return value?? - El Forum - 03-07-2008

[eluser]zilverdistel[/eluser]
I'd like to know what return value to expect when loading a model like this:

Code:
$user1 = $this->load->model('user_model');



loading model return value?? - El Forum - 03-07-2008

[eluser]xwero[/eluser]
No value. if there is an error the model doesn't get loaded. If you want to check if the model is loaded witout looking at the log you can do
Code:
if(!class_exists('user_model'))
{
   // error
}
else
{
  // success
}



loading model return value?? - El Forum - 03-07-2008

[eluser]zilverdistel[/eluser]
so, if a model doesn't get loaded, CI does not interrupt the execution process?


loading model return value?? - El Forum - 03-07-2008

[eluser]xwero[/eluser]
[quote author="diederik vandamme" date="1204910002"]so, if a model doesn't get loaded, CI does not interrupt the execution process?[/quote]
no


loading model return value?? - El Forum - 03-07-2008

[eluser]zilverdistel[/eluser]
i find that bizar... most CI methods return false if something fails. Is there a reason for this? If not, it might be an interesting feature for future releases.


loading model return value?? - El Forum - 03-07-2008

[eluser]xwero[/eluser]
It's not that strange Because the only time you are going to get errors is when you are in the development phase and then you use the log to track errors. Even if you are in a rush and you don't have the time to do tests, which you should, you are not going to write code direct on the production server.

If there would be checks everywhere the application/website would run slow.


loading model return value?? - El Forum - 03-07-2008

[eluser]zilverdistel[/eluser]
that's fair enough, tnx xwero