Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion db.php
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ public function query( $query ) {
$elapsed = $this->timer_stop();
++$this->num_queries;

if ( preg_match( '/^\s*SELECT\s+SQL_CALC_FOUND_ROWS\s/i', $query ) ) {
if ( preg_match( '/^\s*SELECT\s+(DISTINCT\s+)?SQL_CALC_FOUND_ROWS\s/i', $query ) ) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to be more strictish and support other query modifiers, this would work:

Suggested change
if ( preg_match( '/^\s*SELECT\s+(DISTINCT\s+)?SQL_CALC_FOUND_ROWS\s/i', $query ) ) {
if ( preg_match( '/^\s*SELECT\s+([A-Z_]+\s+)*SQL_CALC_FOUND_ROWS\s/i', $query ) ) {

Eg; SELECT SOME_MODE DISTINCT SQL_CALC_FOUND_ROWS * FROM...

if ( false === strpos( $query, 'NO_SELECT_FOUND_ROWS' ) ) {
$this->timer_start();
$this->last_found_rows_result = $this->ex_mysql_query( 'SELECT FOUND_ROWS()', $this->dbh );
Expand Down