Try this:

$stack is an array of hashes:

$stack[0] = array(0=>tablename, 1=>insertid());

For each insert you do, push an anonymous array on $stack which includes
the tablename and insertid of the insert.

Then as you continue your inserts, if any of them fail, call a function
which takes that array $stack, and iterate through it, deleting the rows
you just inserted. (see mysql_insert_id() function to get the insert ID)

If none of them do fail, then you are in the clear.  Either unset $stack or
ignore it.


On Wed, 13 Nov 2002, Anthony wrote:

> I have to drop a lot of data into mySQL from PHP.  It will go into quite
> a few different tables.  How can I maintain integrity of the entire
> insert?  I need to do about a dozen inserts on four tables and I need to
> insure that all the inserts are successful or that none of them get
> done.  I'm sort of new at this, so please help me out.  Thanks.
> - Anthony
> --
> PHP Database Mailing List (
> To unsubscribe, visit:

Peter Beckman            Systems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED]                   

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to