svn: /phpdoc/en/trunk/reference/pdo/ error-handling.xml
| From: | Joey Smith | Date: | Sun, 10 Jul 2011 20:20:09 +0000 |
| Subject: | svn: /phpdoc/en/trunk/reference/pdo/ error-handling.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-8455@lists.php.net to get a copy of this message | ||
joey Sun, 10 Jul 2011 20:20:09 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=313120
Log:
Include an example of how to set the PDO error mode
Changed paths:
U phpdoc/en/trunk/reference/pdo/error-handling.xml
Modified: phpdoc/en/trunk/reference/pdo/error-handling.xml
===================================================================
--- phpdoc/en/trunk/reference/pdo/error-handling.xml 2011-07-10 20:18:08 UTC (rev 313119)
+++ phpdoc/en/trunk/reference/pdo/error-handling.xml 2011-07-10 20:20:09 UTC (rev 313120)
@@ -72,6 +72,31 @@
containing the SQLSTATE code, the driver specific error code and driver
specific error string.
</para>
+
+ <refsect1 role="examples">
+ &reftitle.examples;
+ <para>
+ <example><title>Create a PDO instance and set the error mode</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
+$user = 'dbuser';
+$password = 'dbpass';
+
+try {
+ $dbh = new PDO($dsn, $user, $password);
+ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+} catch (PDOException $e) {
+ echo 'Connection failed: ' . $e->getMessage();
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
+ </para>
+ </refsect1>
</chapter>
<!-- Keep this comment at the end of the file