Plugin Directory

Changeset 3123906


Ignore:
Timestamp:
07/23/2024 01:01:11 PM (19 months ago)
Author:
vnsavage
Message:

Improve last error handling: Record the last_error closer to the queries so it's not lost and don't run 'SELECT FOUND_ROWS()' if the query has failed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • hyperdb/trunk/db.php

    r2815858 r3123906  
    952952
    953953            $this->result = $this->ex_mysql_query( $query, $this->dbh );
     954            $this->last_error = $this->ex_mysql_error( $this->dbh );
    954955
    955956            if ( $statement_after_query ) {
     
    960961            ++$this->num_queries;
    961962
    962             if ( preg_match( '/^\s*SELECT\s+SQL_CALC_FOUND_ROWS\s/i', $query ) ) {
     963            if ( preg_match( '/^\s*SELECT\s+SQL_CALC_FOUND_ROWS\s/i', $query ) && false !== $this->result ) {
    963964                if ( false === strpos( $query, 'NO_SELECT_FOUND_ROWS' ) ) {
    964965                    $this->timer_start();
    965966                    $this->last_found_rows_result = $this->ex_mysql_query( 'SELECT FOUND_ROWS()', $this->dbh );
    966967                    $elapsed                     += $this->timer_stop();
     968                    $this->last_error             = $this->ex_mysql_error( $this->dbh );
    967969                    ++$this->num_queries;
    968970                    $query .= '; SELECT FOUND_ROWS()';
     
    986988            }
    987989        }
    988 
    989         $this->last_error = $this->ex_mysql_error( $this->dbh );
    990990
    991991        if ( $this->last_error ) {
Note: See TracChangeset for help on using the changeset viewer.