I'm having an issue with mysqli->affected_rows.
Here's my example table:
Name, Age
John Doe, 26
Bob Doe, 35
And here's my example update statement:
UPDATE table SET Age = 26 WHERE Age > 0;
Running the UPDATE and displaying mysqli->info gives me: "Rows matched: 2 Changed: 1 Warnings: 0".
I can call mysqli->affected_rows to return the Changed value. However, I want to know the Matched value. Is there a way to get the Matched value (aside from parsing the mysqli->info string)?
MySQLi Affected vs Matched
Moderator: General Moderators
-
TheAlmightyGuru
- Forum Newbie
- Posts: 2
- Joined: Fri Aug 12, 2011 12:59 pm
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: MySQLi Affected vs Matched
affected_rows would return matched rows number if you connected using mysqli_real_connect() passing MYSQLI_CLIENT_FOUND_ROWS in flags parameter. As far as I know you can't get both at the same time unless you parse the info string.
-
TheAlmightyGuru
- Forum Newbie
- Posts: 2
- Joined: Fri Aug 12, 2011 12:59 pm
Re: MySQLi Affected vs Matched
Thank you Weirdan, that solved my problem.
With that flag set, affected_rows now returns the matched records instead of the changed records.
With that flag set, affected_rows now returns the matched records instead of the changed records.
Re: MySQLi Affected vs Matched
Nice Weirdan, I will remember that one myself... lol
Best wishes
Best wishes