diff --git a/db.php b/db.php index 4239cf2..4421cf6 100644 --- a/db.php +++ b/db.php @@ -435,6 +435,12 @@ public function db_connect( $query = '' ) { if ( ! $this->ex_mysql_select_db( DB_NAME, $this->dbh ) ) { return $this->log_and_bail( 'We were unable to select the database' ); } + + // Set the SQL mode. + if ( is_callable( array( $this, 'set_sql_mode' ) ) ) { + $this->set_sql_mode(); + } + if ( ! empty( $this->charset ) ) { $collation_query = "SET NAMES '$this->charset'"; if ( ! empty( $this->collate ) ) { @@ -773,7 +779,12 @@ public function db_connect( $query = '' ) { $this->set_charset( $this->dbhs[ $dbhname ], $charset, $collate ); - $this->dbh = $this->dbhs[ $dbhname ]; // needed by $wpdb->_real_escape() + $this->dbh = $this->dbhs[ $dbhname ]; // needed by $wpdb->_real_escape() and `$wpdb->set_sql_mode()` + + // Set the SQL mode. + if ( is_callable( array( $this, 'set_sql_mode' ) ) ) { + $this->set_sql_mode(); + } $this->last_used_server = compact( 'host', 'user', 'name', 'read', 'write' );