what to do on PHP PDO execute() returns false?

php

Solution

It really depends on what kind of query you execute. If it's a part of a transaction, you might want to rollback it. If it is crucial to subsequent program execution, you will surely want to stop it and display an error message. If your program can live without it, you can just ignore it or handle in any way you believe is right.

It returns false when there was an error. It might happen due to lack of connection, improper parameters etc.

Problem

The php manual (http://www.php.net/manual/en/pdostatement.execute.php) mentions at Return Values: "Returns TRUE on success or FALSE on failure." I'm writing a php script with several PDO::execute statements. What should be done when PHP:PDO would indeed return FALSE? Stop the entire script (call exit()) or continue or something else? What are possible reasons for Execute() returning false? Or is returning false only a very theoretical scenario that almost never happens in reel live?

Original source

Related problems