I have a custom error handler in place but I need to know where to test for errors within my prepared statement.
Do I test at all prepared()
, bind()
, execute()
and store_result()
stages or just selected stages?
$statement = $databaseHandler->mysqli->prepare($query) or trigger_error($mysqli->error);
$statement->bind_param('s', $userIp) or trigger_error($mysqli->error);
$statement->execute() or trigger_error($mysqli->error);
$statement->store_result() or trigger_error($mysqli->error);
Do i even have to check for errors when looking for num_rows
or would that just be php failing to do a basic job as its no longer communicating with the mysqli server so nothing should go wrong?
What's the point you should stop looking for errors, is it after execute()
? as store_result()
not working would be php failing to do its job, which would be the server not actually functioning?
Also I have seen code where the prepare()
stage is just surrounded in an if statement for errors, by doing this does this mean an error in the other stages would not be handled? Is the prepared stage most likely to go wrong the most?