Re: Transactions - working but unsure about steps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
-----------------------------------------------------------------

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux