Re: PDO does not trow Exceptions for queries

From: Andreas Kalsch <andreaskalsch(at)gmx(dot)de>
To: pgsql-php(at)postgresql(dot)org
Subject: Re: PDO does not trow Exceptions for queries
Date: 2009-08-03 23:04:45
Message-ID: 4A776D0D.4040707@gmx.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.
>

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Eric Chamberlain 2009-08-19 20:20:04 Stored procedures, PDO, and PHP issue
Previous Message Chris 2009-08-03 22:50:17 Re: PDO does not trow Exceptions for queries