pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Struck <struck.d@retrovirology.lu>
To: Michael Glaesemann <grzm@myrealbox.com>
Cc: pgsql-php@postgresql.org
Subject: Re: Reducing duplicated business rules
Date: Thu, 6 Nov 2003 16:52:10 +0100
Message-ID: <20031106165210.6b46bbb7.struck.d@retrovirology.lu> (raw)
In-Reply-To: <096944BE-0EE7-11D8-B410-0005029FC1A7@myrealbox.com>
References: <096944BE-0EE7-11D8-B410-0005029FC1A7@myrealbox.com>

> 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.d@retrovirology.lu



view thread (10+ messages)  latest in thread

Message-ID: <20031106165210.6b46bbb7.struck.d@retrovirology.lu>
Permalink:  ../20031106165210.6b46bbb7.struck.d@retrovirology.lu/
Also on:    postgresql.org/message-id/20031106165210.6b46bbb7.struck.d@retrovirology.lu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: struck.d@retrovirology.lu, grzm@myrealbox.com
  Subject: Re: Reducing duplicated business rules
  In-Reply-To: <20031106165210.6b46bbb7.struck.d@retrovirology.lu>
  References: <096944BE-0EE7-11D8-B410-0005029FC1A7@myrealbox.com> <20031106165210.6b46bbb7.struck.d@retrovirology.lu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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