Skip site navigation (1) Skip section navigation (2)

Re: PDO does not trow Exceptions for queries

From: Chris <dmagick(at)gmail(dot)com>
To: Andreas Kalsch <andreaskalsch(at)gmx(dot)de>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: PDO does not trow Exceptions for queries
Date: 2009-08-03 22:50:17
Message-ID: 4A7769A9.6020205@gmail.com (view raw or flat)
Thread:
Lists: 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/


In response to

Responses

pgsql-php by date

Next:From: Andreas KalschDate: 2009-08-03 23:04:45
Subject: Re: PDO does not trow Exceptions for queries
Previous:From: Carol WalterDate: 2009-08-03 20:11:07
Subject: Re: pg_query_params version?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group