From: | Daniel Struck <struck(dot)d(at)retrovirology(dot)lu> |
---|---|
To: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
Cc: | pgsql-php(at)postgresql(dot)org |
Subject: | Re: Reducing duplicated business rules |
Date: | 2003-11-06 15:52:10 |
Message-ID: | 20031106165210.6b46bbb7.struck.d@retrovirology.lu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
> Of course PostgreSQL will throw back an error if I tried to insert or
> update data that will make the check constraint untrue, which is as it
> should be. Is there any way to use this feedback from Postgres instead
> of running my own checks in PHP, and still provide useful feedback to
> the user (rather than the naked PostgreSQL error code)?
I am right now also looking how to get a feedback from a postgrsql-check back to php.
I thought about using named constraints:
CREATE TABLE test (
id SERIAL,
[whatever fields you need]
CONSTRAINT "!!!#Please check XYZ in the formular#" CHECK ([whatever you like to test])
);
Next, I would check in php if an error occured in the sql-query, if the error includes "!!!" in the error message from postgresql I would display the formular again with the values already entered and I would display as a feedback to the user the string between the two "##":
Please check XYZ in the formular
One drawback is of course that it will only give feedback from one error at a time.
greetings,
Daniel
--
Retrovirology Laboratory Luxembourg
Centre Hospitalier de Luxembourg
4, rue E. Barblé
L-1210 Luxembourg
phone: +352-44116105
fax: +352-44116113
web: http://www.retrovirology.lu
e-mail: struck(dot)d(at)retrovirology(dot)lu
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Glaesemann | 2003-11-06 16:16:54 | Re: Reducing duplicated business rules |
Previous Message | Christopher Kings-Lynne | 2003-11-06 15:04:05 | Re: pg_dump + cronjob |