I am trying to get to grips with pdo. I have the below function:
function get_editusers($db)
{
$result = $db->query("SELECT firstname, middlename,surname,fullname,gender, birthdate,homelanguage,department,employeetype,employeestatus,idnumber FROM Persons where employeeid='$employeeid'");
return $result;
}
$useredit = get_editusers($db);
how do I know if the query ran correctly? if it was not successful I would like a certain action to be performed but not sure how to ‘catch’ the error.
if($useredit="failed"){ action if failed} else { action if true}
Thanks in advance,
1 Answer