Re: Looping advice sought
| From: | DL Neil | Date: | Tue, 22 Jan 2002 12:19:30 +0000 |
| Subject: | Re: Looping advice sought | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-16048@lists.php.net to get a copy of this message | ||
George,
> I am about to start on a script page which will loop
> thru a MySQL table and update records depending on the
> actions of the user.
>
> I propose to loop through, row by row performing a
> separate UPDATE statement for each row, unless someone
> can advise me of a better way (2d array?).
It would be more efficient to go to the database once, than to make multiple calls.
However you are talking UPDATE (also applies to DELETE) and therefore due care and attention must be
applied.
UPDATE tblNm SET iq=0 WHERE teamsupported="Rangers";
is likely to affect numerous records (to say nothing of your health!). Whereas if you only want to
reflect a
change in a single customer's order record
UPDATE tblNm SET source="someuniversitylibrary"
WHERE requestId=1678 and component="part A";
So to achieve a more useful answer can you expand on the description of the transaction and/or
"actions of the
user" - or maybe some pseudo-code, please?
=dn