X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 7FA0BD1D88C for ; Mon, 24 Nov 2003 19:09:28 +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 08456-04 for ; Mon, 24 Nov 2003 15:08:58 -0400 (AST) Received: from mx-bos.paetec.net (mx-bos.paetec.net [64.80.233.226]) by svr1.postgresql.org (Postfix) with ESMTP id 9D5F2D1DA6D for ; Mon, 24 Nov 2003 15:08:04 -0400 (AST) Received: from [192.168.1.100] ([64.80.80.230]) by mx-bos.paetec.net (8.12.10/8.12.10) with ESMTP id hAOJ81tK008203; Mon, 24 Nov 2003 14:08:01 -0500 (EST) Subject: Re: Reducing duplicated business rules From: Ryan Mahoney Reply-To: ryan@flowlabs.com To: Tom Hebbron Cc: pgsql-php@postgresql.org In-Reply-To: References: <20031106165210.6b46bbb7.struck.d@retrovirology.lu> <714126A2-1082-11D8-B410-0005029FC1A7@myrealbox.com> <20031109163716.08fed5de.struck.d@retrovirology.lu> Content-Type: multipart/mixed; boundary="=-G51eToX8oYDcg3zIKE4Y" Organization: Flowlabs Message-Id: <1069700924.27340.20.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.1 (1.2.1-3) Date: 24 Nov 2003 14:08:44 -0500 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/52 X-Sequence-Number: 2445 --=-G51eToX8oYDcg3zIKE4Y Content-Type: text/plain Content-Transfer-Encoding: 7bit We have done the same thing that you are doing - but we don't read the database metadata at all, we just create an xml file when we create the table that describes the datatype and html display type so we can have custom types such as email address type, etc. I thought about doing this the way you have, but ultimately I decided that depending on the database metadata would be too limited for my needs. Attached is an xml file that describes one of our tables. We have a custom application that automatically build interfaces to add, edit, list, view, and delete data based on this xml file with validation. -r On Thu, 2003-11-20 at 14:36, Tom Hebbron wrote: > Hi group, > > I'm interested to see that other people have hit this problem. In the last > few months I've been writing and re-writing PHP classes to access a > postgreSQL database for a CMS. > Here is a rough overview of the way I've dealt with the validation problem. > > tuple class > array of attribute class objects > > initialisation fetches metadata about the table/view the tuple (row) > belongs to (attribute types, domains & built in CHECK constraints, foriegn > keys, not null) > this data comes from a set of attribute metadata views (built from > system catalogs and optimised - further optimisation is envisaged for PG > 7.4) > the tuple / attribute metadata allows us to do the following things > > foreign key attributes can auto-build a list of options for a