I recently switched from using MySQLI to using PDO and it seems like PDO doesn't always let you know when there is an error when you run a query that errors.
With MYSQLI, you could do:
if($dbh->query("SELECT ...") === false) {
echo "Error";
}
If there was an SQL syntax error or an improperly named column or whatnot, this would always happen (which is the desired result).
With PDO, when you do:
if($dbh->query("SELECT ...") === false) {
echo "Error";
}
This does not always happen when you have the same sort of aforementioned errors!
So how do I get the same desired effect with PDO? I want to be able to have the case in the above piece of code happen ANYTIME there is an issue with the query. In other words, unless I get some sort of result set back (be it no records or some number of records), I want $dbh->query(...) to return false.