These two methods are nearly identical. Practically, you will probably
never see a performance difference. The time it takes to perform a query
is an order of magnitude greater than the time it takes to allocate
space for and iterate through an array. I would imagine that you will
never notice a difference between these two examples, even under heavy
loads. Perhaps Peter can speak to heavy loads better than I.


On Sat, 2002-12-07 at 16:53, rolf vreijdenberger wrote:
> 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
> -- 
> PHP Database Mailing List (
> To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to