pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PDO does not trow Exceptions for queries
3+ messages / 2 participants
[nested] [flat]

* PDO does not trow Exceptions for queries
@ 2009-08-03 18:37 Andreas Kalsch <andreaskalsch@gmx.de>
  2009-08-03 22:50 ` Re: PDO does not trow Exceptions for queries Chris <dmagick@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Andreas Kalsch @ 2009-08-03 18:37 UTC (permalink / raw)
  To: pgsql-php

$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');


What my phpinfo() says:

PHP Version 5.2.6-1+lenny3

This server is protected with the Suhosin Patch 0.9.6.2

PDO
PDO support    enabled
PDO drivers     pgsql

pdo_pgsql
PDO Driver for PostgreSQL    enabled
PostgreSQL(libpq) Version     8.3.7
Module version     1.0.2
Revision     $Id: pdo_pgsql.c,v 1.7.2.11 2006/03/14 10:49:18 edink Exp $

pgsql
PostgreSQL Support    enabled
PostgreSQL(libpq) Version     8.3.7
Multibyte character support     enabled
SSL support     enabled
Active Persistent Links     0
Active Links     0
pgsql.allow_persistent    On    On
pgsql.auto_reset_persistent    Off    Off
pgsql.ignore_notice    Off    Off
pgsql.log_notice    Off    Off
pgsql.max_links    Unlimited    Unlimited
pgsql.max_persistent    Unlimited    Unlimited



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PDO does not trow Exceptions for queries
  2009-08-03 18:37 PDO does not trow Exceptions for queries Andreas Kalsch <andreaskalsch@gmx.de>
@ 2009-08-03 22:50 ` Chris <dmagick@gmail.com>
  2009-08-03 23:04   ` Re: PDO does not trow Exceptions for queries Andreas Kalsch <andreaskalsch@gmx.de>
  0 siblings, 1 reply; 3+ messages in thread

From: Chris @ 2009-08-03 22:50 UTC (permalink / raw)
  To: Andreas Kalsch <andreaskalsch@gmx.de>; +Cc: pgsql-php

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/




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: PDO does not trow Exceptions for queries
  2009-08-03 18:37 PDO does not trow Exceptions for queries Andreas Kalsch <andreaskalsch@gmx.de>
  2009-08-03 22:50 ` Re: PDO does not trow Exceptions for queries Chris <dmagick@gmail.com>
@ 2009-08-03 23:04   ` Andreas Kalsch <andreaskalsch@gmx.de>
  0 siblings, 0 replies; 3+ messages in thread

From: Andreas Kalsch @ 2009-08-03 23:04 UTC (permalink / raw)
  To: pgsql-php

In this case it was my false - I forgot to enable error reporting on the 
PHP side.
Now everything works like I would expect it.


Chris schrieb:
> 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.
>




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2009-08-03 23:04 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-08-03 18:37 PDO does not trow Exceptions for queries Andreas Kalsch <andreaskalsch@gmx.de>
2009-08-03 22:50 ` Chris <dmagick@gmail.com>
2009-08-03 23:04   ` Andreas Kalsch <andreaskalsch@gmx.de>

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