Welcome Guest, Not a member yet? Register   Sign In
Query doesn't seem to run but there are no errors in my log
#1

[eluser]johnwbaxter[/eluser]
I have a controller that loads a model and runs the function in the model.

This is my model:

Code:
function getorders()
    {
    
        $order_cust_id = $this->session->userdata['id'];

        log_message('info', $order_cust_id);

        $this->db->select('orderid, cust_id, status, price, timestamp');

    log_message('info', 'The select part has run');

        $this->db->from('orders');

    log_message('info', 'The from part has run');

    $this->db->where('cust_id', $order_cust_id);

    log_message('info', 'The where part has run');

        return $this->db->get();

        log_message('debug', $this->db->last_query());

    }

From looking in the log, the last message that is logged is "The where part has run" and then it loads the next part of the controller which is loading a view. There are no errors inbetween the last message shown and loading the view.

The query is obviously not run as the "this->db->last_query is not logged but there is no error in the log!

What in earth is going on!

If anyone can help they would be saving me from spiralling into lunacy...
#2

[eluser]xwero[/eluser]
the log message debug will never be added because your return the function before it. return exists the function.
#3

[eluser]johnwbaxter[/eluser]
Okay. I've removed that part but it is still not working, it just loads a blank page and there are still no errors in the log.

Any ideas?

The thing is, it was working and then it wasn't. I'm sure i haven't changed anything within the controller function that calls this model, or the model function or the associated view.
#4

[eluser]gtech[/eluser]
have you got db_debug set to true or false in config/database.php?

if true you should at least be getting an error message on the browser.
#5

[eluser]johnwbaxter[/eluser]
I have got it set to true.

I think i have narrowed down the problem to the actual loading of the model itself. It is not the query above that is at fault it is another function below that is causing the model not to load properly.

I don't know why there is no error though and i'm now going through the other function to see what the issue might be.

Very very very weird. Thanks for the suggestions guys, you can mark this closed!




Theme © iAndrew 2016 - Forum software by © MyBB