How can I recognize a fetch error or empty result from a execute error with php PDO mysql driver?
$sql = \' SELECT * \'; $sql .= \' FROM test \'; $sql
If there's an error then PDO will throw an exception which you can catch. Wrap your code with a try catch and that should catch any exceptions.
try { $rs = $db->prepare('SELECT * FROM foo'); $rs->execute(); $foo = $rs->fetchAll(); } catch (Exception $e) { echo 'Error: '.$e->getMessage(); }