pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris <dmagick@gmail.com>
To: Andreas Kalsch <andreaskalsch@gmx.de>
Cc: pgsql-php@postgresql.org
Subject: Re: PDO does not trow Exceptions for queries
Date: Tue, 04 Aug 2009 08:50:17 +1000
Message-ID: <4A7769A9.6020205@gmail.com> (raw)
In-Reply-To: <4A772E6F.1000108@gmx.de>
References: <4A772E6F.1000108@gmx.de>

Andreas Kalsch wrote:
> $C->DB is my connection, but no exceptions will be thrown for the last 
> queries - althogh there is an error (whoch the command line would show).
> Is there another option to activate throwing of exceptions?
> 
> 
> $C->DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
> 
> $C->DB->query('DROP TABLE key');
> 
> $C->DB->query('CREATE TABLE key ( id SERIAL NOT NULL PRIMARY KEY, k TEXT 
> NOT NULL UNIQUE )');
> 
> $S = $C->DB->prepare('INSERT INTO key (k)
> SELECT lower(k) FROM current_node_tags LIMIT 100');

prepare returns a 'pdostatement' which you then have to execute:

$S->execute();

This should generate an exception.

-- 
Postgresql & php tutorials
http://www.designmagick.com/




view thread (3+ messages)  latest in thread

Message-ID: <4A7769A9.6020205@gmail.com>
Permalink:  ../4A7769A9.6020205@gmail.com/
Also on:    postgresql.org/message-id/4A7769A9.6020205@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: dmagick@gmail.com, andreaskalsch@gmx.de
  Subject: Re: PDO does not trow Exceptions for queries
  In-Reply-To: <4A7769A9.6020205@gmail.com>
  References: <4A772E6F.1000108@gmx.de> <4A7769A9.6020205@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox