Re: Multiple Inserts with mySQL

From: Date: Wed, 13 Nov 2002 22:52:18 +0000
Subject: Re: Multiple Inserts with mySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-23313@lists.php.net to get a copy of this message
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. Peter 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 (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > --------------------------------------------------------------------------- Peter Beckman Systems Engineer, Fairfax Cable Access Corporation beckman@purplecow.com http://www.purplecow.com/ ---------------------------------------------------------------------------

« previous php.db (#23313) next »