This is a discussion on [PDO] Detecting SQL errors? within the PHP Language forums, part of the PHP Programming Forums category; Hello One of my PHP5 scripts wouldn't run right because I didn't use the right number of parameters ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello
One of my PHP5 scripts wouldn't run right because I didn't use the right number of parameters in the SQL command, but PHP didn't return any error, even after adding a try/catch section: ====== if(!$dbh->query($sql)->fetchColumn()) { try { //Expects two parameters -> won't run $sql = "INSERT INTO mytable VALUES (NULL)"; $dbh->exec($sql); } catch (Exception $e) { echo 'Exception raised : ', $e->getMessage(), "\n"; } } ====== Is there a way to check that a SQL command completed correctly? Thank you. |
|
|||
|
Gilles Ganault wrote:
[...] > Is there a way to check that a SQL command completed correctly? Check out those: http://php.net/manual/en/pdo.errorcode.php http://php.net/manual/en/pdo.errorinfo.php Cheers, -- ---------------------------------- Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org- Un ordenador no es un televisor ni un microondas, es una herramienta compleja. |
|
|||
|
On Tue, 06 May 2008 00:17:14 +0200, Iván Sánchez Ortega
<ivansanchez-alg@rroba-escomposlinux.-.punto.-.org> wrote: >Check out those: >http://php.net/manual/en/pdo.errorcode.php >http://php.net/manual/en/pdo.errorinfo.php Thanks guys. Problem solved. |