pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedsql problem with php
4+ messages / 3 participants
[nested] [flat]
* sql problem with php
@ 2004-11-05 14:33 Flavio Fonseca <ff@dr.ufu.br>
0 siblings, 1 reply; 4+ messages in thread
From: Flavio Fonseca @ 2004-11-05 14:33 UTC (permalink / raw)
To: pgsql-php
Hi,
I am having a problem with a system I developed using php with postgres.
Take a look at this:
Welcome to psql 7.3.2, the PostgreSQL interactive terminal.
NetAdmin=# delete from operador where oplogin = 'ff';
ERROR: fk_historicosessao_operador referential integrity violation - key in
operador still referenced from historicosessao
and then, this:
Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
NetAdmin=# delete from operador where oplogin = 'ff';
ERROR: update or delete on "operador" violates foreign key constraint
"fk_historicosessao_operador" on "historicosessao"
I am not able to get a error_number in pgsql errors, only the error message.
So when I used pgsql 7.3 a used the string "referential integrity violation"
to detect this error, but on version 7.4 of pgsql this string was replaced
with "violates foreign key constraint" .
Anyone has a definitive solution on this or the way is to wait and change all
my code on future releases of pgsql?
Thank you all for the attention.
--
Att.
Flavio Fonseca
Administrador de Redes
Divisao de Redes
Universidade Federal de Uberlandia
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sql problem with php
@ 2004-11-06 01:40 ljb <ljb220@mindspring.com>
parent: Flavio Fonseca <ff@dr.ufu.br>
0 siblings, 1 reply; 4+ messages in thread
From: ljb @ 2004-11-06 01:40 UTC (permalink / raw)
To: pgsql-php
ff@dr.ufu.br wrote:
> Hi,
>
> I am having a problem with a system I developed using php with postgres.
>...
>
> I am not able to get a error_number in pgsql errors, only the error message.
> So when I used pgsql 7.3 a used the string "referential integrity violation"
> to detect this error, but on version 7.4 of pgsql this string was replaced
> with "violates foreign key constraint" .
> Anyone has a definitive solution on this or the way is to wait and change all
> my code on future releases of pgsql?
Unfortunately this is a limitation of the PHP PostgreSQL extension.
PostgreSQL provids access to error numbers (I think as of 7.4)
through libpq PQerrorField(), but PHP doesn't give you access to this yet.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sql problem with php
@ 2004-11-06 15:37 Robert Treat <xzilla@users.sourceforge.net>
parent: ljb <ljb220@mindspring.com>
0 siblings, 1 reply; 4+ messages in thread
From: Robert Treat @ 2004-11-06 15:37 UTC (permalink / raw)
To: ljb <ljb220@mindspring.com>; +Cc: pgsql-php
On Friday 05 November 2004 20:40, ljb wrote:
> ff@dr.ufu.br wrote:
> > Hi,
> >
> > I am having a problem with a system I developed using php with
> > postgres. ...
> >
> > I am not able to get a error_number in pgsql errors, only the error
> > message. So when I used pgsql 7.3 a used the string "referential
> > integrity violation" to detect this error, but on version 7.4 of pgsql
> > this string was replaced with "violates foreign key constraint" .
> > Anyone has a definitive solution on this or the way is to wait and change
> > all my code on future releases of pgsql?
>
> Unfortunately this is a limitation of the PHP PostgreSQL extension.
> PostgreSQL provids access to error numbers (I think as of 7.4)
> through libpq PQerrorField(), but PHP doesn't give you access to this yet.
>
Actually I believe you can get it:
http://us2.php.net/manual/en/function.pg-result-error.php
though this will only work in pg74 or greater.
--
Robert Treat
Build A Brighter Lamp :: Linux Apache {middleware} PostgreSQL
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: sql problem with php
@ 2004-11-06 22:53 ljb <ljb220@mindspring.com>
parent: Robert Treat <xzilla@users.sourceforge.net>
0 siblings, 0 replies; 4+ messages in thread
From: ljb @ 2004-11-06 22:53 UTC (permalink / raw)
To: pgsql-php
xzilla@users.sourceforge.net wrote:
> On Friday 05 November 2004 20:40, ljb wrote:
>> ff@dr.ufu.br wrote:
>> > Hi,
>> >
>> > I am having a problem with a system I developed using php with
>> > postgres. ...
>> >
>> > I am not able to get a error_number in pgsql errors, only the error
>> > message. So when I used pgsql 7.3 a used the string "referential
>> > integrity violation" to detect this error, but on version 7.4 of pgsql
>> > this string was replaced with "violates foreign key constraint" .
>> > Anyone has a definitive solution on this or the way is to wait and change
>> > all my code on future releases of pgsql?
>>
>> Unfortunately this is a limitation of the PHP PostgreSQL extension.
>> PostgreSQL provids access to error numbers (I think as of 7.4)
>> through libpq PQerrorField(), but PHP doesn't give you access to this yet.
>>
>
> Actually I believe you can get it:
> http://us2.php.net/manual/en/function.pg-result-error.php
>
> though this will only work in pg74 or greater.
No, I don't think PHP has this capability (get the value of an error
message subfield). The pg_result_error() you refer to gives you the whole
message, which makes it hard for a program to determine exactly what went
wrong.
On the documentation page you point to, somebody added a comment
referencing his own patch. The patch adds a PHP function called
pg_result_error_field(), which lets a script get at the individual
PostgreSQL error message fields. This would be a nice addition to PHP, but
I don't know if the patch was submitted or accepted. It isn't in the latest
PHP 4 release, 4.3.9. As you point out, however, it won't help the original
poster still dealing with PostgreSQL 7.3, which doesn't have this feature.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2004-11-06 22:53 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-11-05 14:33 sql problem with php Flavio Fonseca <ff@dr.ufu.br>
2004-11-06 01:40 ` ljb <ljb220@mindspring.com>
2004-11-06 15:37 ` Robert Treat <xzilla@users.sourceforge.net>
2004-11-06 22:53 ` ljb <ljb220@mindspring.com>
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