Here's a question of efficiency.

I have an application in PHP using MySQL.

Users select items on a form and each selected item represents a change in a table row. It is possible that 100s of changes might be chosen from a single form.

Which is likely to be faster/more efficient?

multiple queries like...
$query="UPDATE some_table SET x='$y' WHERE id='$z[$key]'";
$result=mysql_query($query);

or one huge query like...
$query="UPDATE some_table SET x='$y' WHERE id='$z[$key]'
        OR id='$z[$another_key]' OR id='$z[$another_key]
        OR id='$z[$another_key]"; etc?
$result=mysql_query($query);

In the latter, PHP would have to construct the WHERE string, which would require some processing power as well. Is there a limit to how many OR's can be added to a mysql query? No - don't answer that, I'll look in the manual.

Many thanks,

Jeff

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

Reply via email to