Re: Transactions - working but unsure about steps
| From: | Martín Marqués | Date: | Sat, 16 Oct 2004 14:48:47 +0000 |
| Subject: | Re: Transactions - working but unsure about steps | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-36848@lists.php.net to get a copy of this message | ||
El Sáb 16 Oct 2004 11:36, Stuart Felenstein escribió:
> I think you are adding a conditonal /validaton
> statement as the constraint ? More then x characters
> will generate an error.
I was tryiong to generate a validation that would fail with certain inserts
(or modification of a register). Using more then 25 characters in the second
field would yield the same result.
> My understaning is an error in mysql transaction will
> rollback should rollback the entire set of
> transactions.
Thats how transactional databases work (in a theorical way, but also practical
in most cases).
> error handling for each statement- values will be
> coming from user input into form, my validations will
> be in the form.
> I've also thought about checking for effected rows and
> then if == 0 , stopping the transaction, but that
> seems redundant to what I believe is the way mysql
> transactions should work.
Why don't you try using PEAR::DB, set autocommit to false and work like this:
// supose $db is a database objet which already has a conection made
$db->autocommit(false);
$db->query("INSERT INTO ...");
$db->query("INSERT INTO ...");
$db->query("INSERT INTO ...");
$db->commit();
That should work, if the database is transactional.
--
11:40:02 up 34 days, 1:58, 2 users, load average: 0.24, 0.33, 0.35
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------