Re: error returning with PEAR::DB

From: Date: Wed, 31 Mar 2004 13:28:02 +0000
Subject: Re: error returning with PEAR::DB
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-11558@lists.php.net to get a copy of this message
On Wed, 31 Mar 2004, Lukas Smith wrote: > > > > That's the wrong way to proceed. > > If you have a UNIQUE key, you first have to verify that the values you are > > inserting are valid ones: > > > > SELECT * FROM tabname WHERE unique condition > > > > Then verify that there are no rows to fetch with $res->numRows() and there > > you can do the insert, or through a message to the user asking for a > > different value. > > and then you have to make the entire operation atomic, since otherwise > someone could insert something inbetween your select and your insert. > > the database constraints are more than a last barrier to failure in my > eyes. they also assist in the functinality of the system. > > but now we are getting into philosophie $db->autocommit(false) :-) If atomicity is important you should choose a database that garanties transactions. Else live with the posibility of having problems. -- 10:26:02 up 22 days, 14:54, 5 users, load average: 0.06, 0.03, 0.00 ----------------------------------------------------------------- Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar' Centro de Telematica | DBA, Programador, Administrador Universidad Nacional del Litoral -----------------------------------------------------------------

« previous php.pear.general (#11558) next »