-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL Affected_Rows() returns number of rows selected instead of false for SELECT statements #604
Comments
Database? Driver? PHP Version? ADOdb Version? |
Database: MySQL 5.7 |
For references... I just tested these too PHP Version: 7.2.25 I do SELECT * from table limit 1 and Affected_Rows(); returns 1 |
This is due to a change in the behavior of the underlying mysqli_affected_rows(), which according to The PHP documentation, now acts as mysqli_num_rows() for SELECT statements. In order to maintain cross-database compatibility, we need to suppress this behavior. |
Thanks, so for all purposes, we should be able to use Affected_Rows(); on all SELECT's as well and can consider it reliable? |
No, you should not, because no other database supports it. The code will be changed so that it conforms to our standard, i.e. It will return false for SELECT statements |
Should we use RecordCount(); instead? |
absolutely |
Maybe the example on https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:affected_rows should include an insert query too, ideally with 2 or 3 row values in the insert query to have a number >1 on success. And maybe remove the select example there to avoid confusion or add an explanation. It is unclear from the example if table act contains just no rows or means 'error', so the 'Return false' there might be misinterpreted. Otherwise this issue can be closed? |
If you want to create a small example and paste it in here, I will happily update the documentation with it |
The mysql affected rows returns a valid value when used against a SELECT statement. This does not conform to the ADOdb standard which requires it to return false
…s, see #604 The mysql affected_rows works as a rowcount() function when called against a select statement. It should return false for ADOdb statements.
Hi,
For some reason this works... however, from the ADOdb Documentation, its not supposed to:
https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:affected_rows
Database: MySQL 5.7
Driver: Mysqli
PHP Version: PHP 7.0.33
ADOdb Version: V5.18
The text was updated successfully, but these errors were encountered: