Welcome Guest, Not a member yet? Register   Sign In
Trouble with Models
#11

[eluser]Dan Decker[/eluser]
[quote author="swanweb" date="1205724039"]You have 2 views, are they both available:

$this->load->view('tickets');
$this->load->view('error_message');[/quote]

Yes, the idea is that if the login is successful the tickets view will be served, but if it fails then the error_message will be served. It doesn't seem to matter, because simply trying to call the model is what is breaking things. I can remove the call to load the model and everything works fine (doesn't really do anything though, ;-)). If I call the model but don't try to use any functions from it, the same thing happens, so the problem is either in the Model class at large (doubtful, or there would be way more posts on the subject), or in my Models code (more likely, since this is my first model ever).

I can apply a "Band-Aid" by making all of my database call from within the Controller, but I'd rather fix the problem and follow the MVC method for semantic reasons.

TIA,
#12

[eluser]Matthew Lanham[/eluser]
Well i use models all the time so it isn't a CI issue...what error reporting level do you have set in CI, as if this is low you may not see the error thats being presented... set it to E_ALL and try it if its not already E_ALL that is (in case you cant find it it's in the main index.php file line 12ish...
#13

[eluser]Dan Decker[/eluser]
It is set to E_ALL and still nothing.
#14

[eluser]Dan Decker[/eluser]
Allright, I've simplified the model to it's most basic form:
Code:
<?php
class User_model extends Model {
    function User_model()
    {
        parent::Model();
    }
}
?>
When I tried to load this "Model of Nothing..." I still get the same result, a blank page. I rewrote it from scratch to elimnate any potential errors. I KNOW it doesn't do anything, but since that's the point, it shouldn't cause a blank page still, right? I stripped the Controller down to merely load this model and then serve a view, nothing else, and it still just makes a blank page. Here is the only code I'm using in the Controller right now:
Code:
$this->load->model('User_model');
$this->load->view('tickets');
WTF folks, what else can I do?
:ahhh:
#15

[eluser]Dan Decker[/eluser]
OK, now "Basic Model" from above is loading no problemo, I'm gonna add some real code to it and see what happens.

Crossing fingers (that makes it hard to code;-)).
#16

[eluser]Dan Decker[/eluser]
Do you hear the chorus of Angels? That's right, I got this model working, one frakkin' line at a time!

Thanks to you all for your ideas, and for letting me air out my code.
#17

[eluser]Dan Decker[/eluser]
It would be important for me to let everyone know that I think that my folly was Copy & Paste. I copied the example Model from the Docs, and that is where my trouble began. Had I put in the extra effort up front to code the model by hand, I would have saved 2 days of frustration, and would be further along in my code, or at the very least on to the next problem.

Again, thanks to all who offered suggestions!

Lesson learned: Don't be lazy, it's too much work! ;-)
#18

[eluser]Sean Murphy[/eluser]
BTW, you were probably getting a white page because the PHP setting display_errors was set to off, even though error_reporting was set to E_ALL.




Theme © iAndrew 2016 - Forum software by © MyBB