* @return mysqli_result|bool
*/
protected function doQuery( $sql ) {
- $conn = $this->getBindingHandle();
-
- if ( $this->bufferResults() ) {
- $ret = $conn->query( $sql );
- } else {
- $ret = $conn->query( $sql, MYSQLI_USE_RESULT );
- }
-
- return $ret;
+ return $this->getBindingHandle()->query( $sql );
}
/**
* @param string $realServer
* @param string|null $dbName
- * @return bool|mysqli
+ * @return mysqli|null
* @throws DBConnectionError
*/
protected function mysqlConnect( $realServer, $dbName ) {
- # Avoid suppressed fatal error, which is very hard to track down
if ( !function_exists( 'mysqli_init' ) ) {
- throw new DBConnectionError( $this, "MySQLi functions missing,"
- . " have you compiled PHP with the --with-mysqli option?\n" );
+ throw $this->newExceptionAfterConnectError(
+ "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
+ );
}
// Other than mysql_connect, mysqli_real_connect expects an explicit port
}
$mysqli = mysqli_init();
-
- $connFlags = 0;
- if ( $this->flags & self::DBO_SSL ) {
+ // Make affectedRows() for UPDATE reflect the number of matching rows, regardless
+ // of whether any column values changed. This is what callers want to know and is
+ // consistent with what Postgres, SQLite, and SQL Server return.
+ $connFlags = MYSQLI_CLIENT_FOUND_ROWS;
+ if ( $this->getFlag( self::DBO_SSL ) ) {
$connFlags |= MYSQLI_CLIENT_SSL;
$mysqli->ssl_set(
$this->sslKeyPath,
$this->sslCiphers
);
}
- if ( $this->flags & self::DBO_COMPRESS ) {
+ if ( $this->getFlag( self::DBO_COMPRESS ) ) {
$connFlags |= MYSQLI_CLIENT_COMPRESS;
}
- if ( $this->flags & self::DBO_PERSISTENT ) {
+ if ( $this->getFlag( self::DBO_PERSISTENT ) ) {
$realServer = 'p:' . $realServer;
}
return $mysqli;
}
- return false;
+ return null;
}
/**