X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 41D8CD1BACF for ; Thu, 6 Nov 2003 15:53:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 00667-01 for ; Thu, 6 Nov 2003 11:52:39 -0400 (AST) Received: from neuron.admin.healthnet.lu (drill.healthnet.lu [158.64.36.2]) by svr1.postgresql.org (Postfix) with ESMTP id E7E56D1BA5B for ; Thu, 6 Nov 2003 11:52:33 -0400 (AST) Received: from control.dmz.chl.lu ([10.11.1.10]) by neuron.admin.healthnet.lu (8.9.3/8.8.8) with SMTP id QAA04068; Thu, 6 Nov 2003 16:52:29 +0100 (MET) Received: from 172.20.1.146 by control.dmz.chl.lu (InterScan E-Mail VirusWall NT); Thu, 06 Nov 2003 16:48:47 +0100 Received: from samara.atlantis.local by woodstock.inf.chl.lu (8.8.8/1.1.22.3/16Mar00-0417PM) id QAA0000008439; Thu, 6 Nov 2003 16:52:26 +0100 (MET) Date: Thu, 6 Nov 2003 16:52:10 +0100 From: Daniel Struck To: Michael Glaesemann Cc: pgsql-php@postgresql.org Subject: Re: Reducing duplicated business rules Message-Id: <20031106165210.6b46bbb7.struck.d@retrovirology.lu> In-Reply-To: <096944BE-0EE7-11D8-B410-0005029FC1A7@myrealbox.com> References: <096944BE-0EE7-11D8-B410-0005029FC1A7@myrealbox.com> X-Mailer: Sylpheed version 0.9.6claws (GTK+ 1.2.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/14 X-Sequence-Number: 2407 > Of course PostgreSQL will throw back an error if I tried to insert or=20 > update data that will make the check constraint untrue, which is as it=20 > should be. Is there any way to use this feedback from Postgres instead=20 > of running my own checks in PHP, and still provide useful feedback to=20 > the user (rather than the naked PostgreSQL error code)? I am right now also looking how to get a feedback from a postgrsql-check ba= ck 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 lik= e to test]) ); Next, I would check in php if an error occured in the sql-query, if the err= or includes "!!!" in the error message from postgresql I would display the = formular again with the values already entered and I would display as a fee= dback 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 --=20 Retrovirology Laboratory Luxembourg Centre Hospitalier de Luxembourg 4, rue E. Barbl=E9 L-1210 Luxembourg phone: +352-44116105 fax: +352-44116113 web: http://www.retrovirology.lu e-mail: struck.d@retrovirology.lu