logo       

Re: sql problem with php: msg#00003

Subject: Re: sql problem with php
xzilla@xxxxxxxxxxxxxxxxxxxxx wrote:
> On Friday 05 November 2004 20:40, ljb wrote:
>> ff@xxxxxxxxx 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.



---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@xxxxxxxxxxxxxx)



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe