multiple table inserts at the same time
| From: | rolf vreijdenberger | Date: | Sat, 07 Dec 2002 23:53:40 +0000 |
| Subject: | multiple table inserts at the same time | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-23899@lists.php.net to get a copy of this message | ||
hi there,
I have multiple tables in my mysql db.
Users register, and after submitting there are multiple tables that need
inserts.
What is the best way to do this? speedwise, efficiencywise, codewise?
(pseudo code)
A) $sql[]='insert1';
$sql[]='insert2';
$sql[]='insert3';
foreach($sql as $doMe){
mysql_query($doMe);//i left safety checks aside for clarity
}
B)$sql='insert1';
mysql_query($sql);
$sql='insert2';
mysql_query($sql);
$sql='insert3';
mysql_query($sql);
I'd prefer the first method, as it makes for easier updating of the queries
in a centralized place.
but I am wondering what your methods are, and any advantages or
disadvantages known to you.
thanks a lot