How to debug PHP PDO statements

Tips for debugging PHP PDO statements:

get the return value of $statement->execute(). It returns true on success and false on failure.

use $statement->errorInfo(), to find out exactly the error in the query.

Make use of xdebug and netbeans’ debugging capability.

Configure PDO to throw exception when errors occur

$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 

Leave a Reply

Your email address will not be published. Required fields are marked *