Re: Converting Postgres SQL constraint logic to PHP? - Mailing list pgsql-general

From Ken Tanzer
Subject Re: Converting Postgres SQL constraint logic to PHP?
Date
Msg-id CAD3a31Usg4nWy=EhzgvFyv=AEkKL-syKwQEpAYjBVNBRDj-C0g@mail.gmail.com
Whole thread Raw
In response to Re: Converting Postgres SQL constraint logic to PHP?  (Steve Atkins <steve@blighty.com>)
Responses Re: Converting Postgres SQL constraint logic to PHP?  (Ken Tanzer <ken.tanzer@gmail.com>)
List pgsql-general
On Fri, Jun 10, 2016 at 1:47 PM, Steve Atkins <steve@blighty.com> wrote:

You could name the check constraints, catch the errors and use a client-side mapping between constraint name and a friendly error message for display in the web interface.

This seems plausible, but not ideal.  I could get over the aesthetics of sequence gaps, but don't like throwing lots of database errors on principle, and also for silting up my logs.  Seems better to catch these before submitting.

 
You could implement the checks in PHP in the database. https://public.commandprompt.com/projects/plphp/wiki

I'm aiming as much as possible for this to "just work" with standard Postgres, and this approach gets away from that.  Plus people would have to know SQL AND PHP in order to create tables.
 
You could look at one of the existing SQL parsers implemented in PHP, and use those to parse the constraint to a tree from which you could easily pull PHP.

This one sounds most promising!  I took a quick Google, and it looks like there are lots of them, and a heavy Mysql focus.  Anyone have experience or suggestions about which of these might be best, and particularly for Postgres?

Thanks for the suggestions!

Ken
 
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



--
AGENCY Software  
A Free Software data system
By and for non-profits
(253) 245-3801

learn more about AGENCY or
follow the discussion.

pgsql-general by date:

Previous
From: rob stone
Date:
Subject: Re: Converting Postgres SQL constraint logic to PHP?
Next
From: Ken Tanzer
Date:
Subject: Re: Converting Postgres SQL constraint logic to PHP?