error with loading model |
[eluser]babyboss[/eluser]
Following is my display.php code under my model folder, Code: <?php I load the above in myController.php using the following Code: <?php I type the following in my browser address bar: http://localhost/codeigniter2/index.php/...ller/index and I get the following error message: An Error Was Encountered Unable to load the requested class: errors
[eluser]Dam1an[/eluser]
Not sure if it's cauing the problem, but the filename of the controller should be all lower case (use underscores as word seperators) and then the class and constructor should only have the first character capitalized
[eluser]Dam1an[/eluser]
I didn't even notice s/he was loading views in the model, just saw the casing being incorrect in the controller, so made a point of that and went back to work Upon closer inspection, it appears to be a renderer like library, but it's a model :-S Why not use a library for this?
[eluser]babyboss[/eluser]
I am pretty new to codeigniter, the code snippet is from a book I have been reading. I am not sure how I correct the problem.
[eluser]jedd[/eluser]
[quote author="babyboss" date="1245371901"]I am pretty new to codeigniter, the code snippet is from a book I have been reading. I am not sure how I correct the problem.[/quote] If the quote is verbatim - if the author really did try to load a view ($this->load->view...) from a model as you've shown above - then you should probably stop reading that book. The way to correct the problem in the immediate short term is to relocate your view loads into your controller. At least, I expect it'll resolve your problem. Certainly it'll make your life much easier. Think of the controller as being, well, kind of like it was in control. And your model as being subservient to the controller. The model does nothing other than take and receive data (and do whatever fiddling is necessary to your database). The controller talks to the model, and similarly it talks to (and controls) the view(s).
[eluser]gtech[/eluser]
the problem you are having is that errors and menu are not standard CI libraries, CI cannot find the errors library and that is why you are seeing that error message. have you created the libraries in the ..\system\application\libraries directory? Code: //this is the problem line * although loading a view in a model is a tad unauthodox it will still work (I just tested it). *
[eluser]babyboss[/eluser]
Hello, gtech, that is impressive, how did you figure out it's that particular line cause the problem? thank you. |
Welcome Guest, Not a member yet? Register Sign In |