You should either use something like `find_by_id` (which will not produce an error, but return false..) or you can catch the error (you could've found that by looking at the php manual about exceptions btw).
If you use option 1, you should also do something explicit when it returns false (like show a custom error) ofcourse
I still get error if I use find_by_id.
User::find_by_id($id);
Nanne Huiges wrote:
You should either use something like `find_by_id` (which will not produce an error, but return false..) or you can catch the error (you could've found that by looking at the php manual about exceptions btw).
If you use option 1, you should also do something explicit when it returns false (like show a custom error) ofcourse
Helped me, thanks.
(1-3/3)
Subject: Fatal error if record not found
If I am submitting a id that does not exist in the database, php-acticerecord gets a fatal error.
example
$user = User::find(99);
99 doesnt exist and now I will get a fatal error. How do I do so that if the id doesn't exist, don't do anything? Because users can type what ever id they want in the uri (user/profile/{id}) and I don't want to show errors like that on the site for users.