Welcome Guest, Not a member yet? Register   Sign In
Error: Trying to get property of non-object
#1

[eluser]alexandervj[/eluser]
I'm getting this error from my model. I'm pretty sure its because the function is looking in the database table for a row that doesn't exist. Is there a way to make it so that if the row its looking for doesn't exist it just returns $data['sent'] = 0? Here is my function in my model. It works great if the row its looking for is in the database

Code:
function getSent(){
        
        $this->db->where('submit_time', $this->uri->segment(3));  //
        $tempsent = $this->db->get('0_request_details');  // here is the problem - if the function doesnt find the row that matches the line above it doesnt know what to do.
        
        if($tempsent){
            
            $sent = $tempsent->row();
            $data['sent'] = $sent->is_sent;
            
        }
        
        return $data;
    
}


Messages In This Thread
Error: Trying to get property of non-object - by El Forum - 10-22-2014, 12:45 PM
Error: Trying to get property of non-object - by El Forum - 10-23-2014, 08:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB