1 message in com.mysql.lists.perlGetting both "matched" and "affected"...| From | Sent On | Attachments |
|---|---|---|
| Jeremy D. Zawodny | 22 Feb 2000 23:54 |
| Subject: | Getting both "matched" and "affected" rows via DBI?![]() |
|---|---|
| From: | Jeremy D. Zawodny (jzaw...@yahoo-inc.com) |
| Date: | 02/22/2000 11:54:17 PM |
| List: | com.mysql.lists.perl |
I've searched the list archives a bit and haven't found the answer to something that's been bugging me lateley. (A quick browse of the DBD::MySQL code didn't reveal what I was hoping to find, either.) Here's the situation:
I can see that in an UPDATE query on a table such as:
UPDATE mytable SET foo = 1 WHERE bar = 1;
it is optimized to
UPDATE mytable SET foo = 1 WHERE bar = 1 AND foo <> 1;
or something close to that.
Good, that's fine with me. It's faster, and speed is what I'm looking for right now.
From the `mysql' interactive shell, I can run such a query and see both the number of rows matched (by the un-optimized WHERE clause, apparently) and the number of rows affected (meaning actually changed).
Good, because if I can see both numbers my code can make some intelligent decisions and avoid several queries that don't make sense if the # of rows matched is > 1.
However, I can't find a way to get BOTH of those values when talking to the database via DBI and DBD::MySQL.
Have I overlooked something? If so, forgive me. Just point me elsewhere and I'll be on my way.
If not, are there any plans to add this behavior? It doesn't seem that it'd be too difficult? (Heck, I might even try if I can find the spare time...)
Thanks in advance,
Jeremy (promoting MySQL use at Yahoo)
-- Jeremy D. Zawodny, <jzaw...@yahoo-inc.com> Technical Yahoo - Yahoo Finance Desk: (408) 328-7878 Cell: (408) 439-9951




