Re: [PHP-DB] PDO Exception Handling Question
But if there is an error in the "SELECT" query (either syntax error, or reference to missing table), then no exception is raised, and control just continues in the try block with a null result from the query. Is this the intended behaviour? Hey, it's really fun I was looking here and on internals to ask quite the same thing. In fact what I have found is that PDO error default handler is silent. But you can change it using : $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); or $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_WARNING); getMessage() . ""; die(); } $dbh->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $dbh->beginTransaction(); try { $sql = "INSERT INTO produit (idproduit, nom, marque, prix) VALUES (NULL,'CB500', 'Honda', '6000')"; $dbh->exec($sql); $idInsere = $dbh->lastInsertId(); $sql2 = "INSERT INTO disponibilite (idproduit, quantite) VALUES ('$idInsere', 5)"; $dbh->exec($sql2); $dbh->commit(); }catch (PDOException $e){ $dbh->rollBack(); print "Erreur ! : " . $e->getMessage() . ""; } ?> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PDO Exception Handling Question
And also my question is : "Why did the PDO creators (Wez the King?) decide to choose the silent mode for being the default one ?" Why not defining the ERRMODE_WARNING by default ? Or perhaps I misunderstand something, and I would be very happy to learn a bit :) Thx Cyril -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] PDO Exception Handling Question
Read on otn : "PDO_ERRMODE_SILENT This is the default mode; it will simply set the error code for you to inspect using the errorCode() and errorInfo() methods of both the statement and database handle objects. if (!$dbh->exec($sql)) { echo $dbh->errorCode() . ""; $info = $dbh->errorInfo(); // $info[0] == $dbh->errorCode() unified error code // $info[1] is the driver specific error code // $info[2] is the driver specific error string" Cyril PIERRE de GEYER a écrit : And also my question is : "Why did the PDO creators (Wez the King?) decide to choose the silent mode for being the default one ?" Why not defining the ERRMODE_WARNING by default ? Or perhaps I misunderstand something, and I would be very happy to learn a bit :) Thx Cyril -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [PDO] - Using bindParam() third parameter : data_type
Hi all, I am currently working on PDO. Exactly on the bindParam() function. The third parameter data_type seems to be here to force the type of the value ? But when I try : $sql = "INSERT INTO produit (idproduit, nom, marque) VALUES (NULL, :nom, :marque)"; $stmt = $dbh->prepare($sql); $nom = 'Testarossa'; $marque = 'Ferrari' ; $stmt->BindValue(':marque',$marque) ; $stmt->BindParam(':nom',$nom,PDO::PARAM_INT) ; $stmt->execute(); $nom = '250 GTO' ; $stmt->execute(); ?> I was expecting to have either a PHP error or an interger in my database. But in my DB I have : 22 Testarossa Ferrari 23 250 GTO Ferrari It mean that it didn't change if I have the third parameter or not. Or perhaps I miss something. Can someone tole me more ? Or just can someone told me where I can find information about it. Regards, Cyruss -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: php4 to php5 upgradation
You just need to install PHP5 and to change your apache configuration (httpd.conf). If you are a windows user i guess it would be easier for you to use wampserver which allow to switch from PHP5 to PHP4 easily. Regards Cyril Manoj Singh a écrit : Hello all, I am using php4 in windows server. Now i want to use php5, will it is possible to upgrade php4 to php5 or i have to remove php4 and then install php5? Please advise me. Regards Manoj -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php