Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>See the docs about <a href="http://www.php.net/manual/en/pdo.error-handling.php" rel="nofollow">PDO Error handling</a> and this <a href="http://www.php.net/manual/en/pdostatement.errorcode.php#67194" rel="nofollow">comment</a></p> <p>By default you have to check the return of execute. Details can then be found in <a href="http://www.php.net/manual/en/pdostatement.errorinfo.php" rel="nofollow">errorinfo()</a> and <a href="http://www.php.net/manual/en/pdostatement.errorcode.php" rel="nofollow">errorcode()</a></p> <pre><code>if ($sql-&gt;execute === false) { //check return, false on error var_dump($sql-&gt;errorinfo(); //array containing information on error die() } </code></pre> <p>But I would recommened using PDO::ERRMODE_EXCEPTION so that a <a href="http://www.php.net/manual/en/class.pdoexception.php" rel="nofollow">PDOException</a> is thrown on error. This makes your code a bit neater. The basic information is provided by the exception's <a href="http://www.php.net/manual/en/exception.tostring.php" rel="nofollow">__toString()</a> but further information can be found (using an exception's normal methods, see link to docs above).</p> <pre><code>$db = new PDO( /* your connection string */ ); $db-&gt;setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING ); try { $sql = $db-&gt;prepare("INSERT INTO `aliases` (`alias`, `domain`, `added`, `enabled`) VALUES (:alias, :domain, :added, :enabled)"); $sql-&gt;execute(); } catch(PDOException $e) { echo $e; //basic information is provided due to Exception::__toString() die(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload