php fatal uncaught error problem

Sorry, I rarely have freetime to chat, but I will try to help here when I'm online.
You already know good practices, like chaining, the problem is that sometimes you return a boolean true/false, and don't check it, just try to use the chained instance.
One of your code paths return the instance for further chaining, some of the code path in the same function returns a bool.
But later you don't check if it's a bool, just expect it to always be the chained instance. That is why you keep getting these type of errors.
To be more specific: even if my previous reply fixed your problem, you will get the same error if no user will be found.
In User class, find function, around line 74 you check if($data->count()), but according to your action function in DB class it can return false.
So replace if($data->count()) with if($data != false && $data->count()) or if($data && $data->count()).
Always check a variable before trying to use it as an instance, if it can be any other type.
 
Sorry, I rarely have freetime to chat, but I will try to help here when I'm online.
You already know good practices, like chaining, the problem is that sometimes you return a boolean true/false, and don't check it, just try to use the chained instance.
One of your code paths return the instance for further chaining, some of the code path in the same function returns a bool.
But later you don't check if it's a bool, just expect it to always be the chained instance. That is why you keep getting these type of errors.
To be more specific: even if my previous reply fixed your problem, you will get the same error if no user will be found.
In User class, find function, around line 74 you check if($data->count()), but according to your action function in DB class it can return false.
So replace if($data->count()) with if($data != false && $data->count()) or if($data && $data->count()).
Always check a variable before trying to use it as an instance, if it can be any other type.
Thanks alot mate. U are priceless
 
Sorry, I rarely have freetime to chat, but I will try to help here when I'm online.
You already know good practices, like chaining, the problem is that sometimes you return a boolean true/false, and don't check it, just try to use the chained instance.
One of your code paths return the instance for further chaining, some of the code path in the same function returns a bool.
But later you don't check if it's a bool, just expect it to always be the chained instance. That is why you keep getting these type of errors.
To be more specific: even if my previous reply fixed your problem, you will get the same error if no user will be found.
In User class, find function, around line 74 you check if($data->count()), but according to your action function in DB class it can return false.
So replace if($data->count()) with if($data != false && $data->count()) or if($data && $data->count()).
Always check a variable before trying to use it as an instance, if it can be any other type.
I ran into another problem. I just started a new thread. Kindly assist me.
 
Back
Top