use mysqli;
use mysqli_result;
use IP;
+use stdClass;
/**
* Database abstraction object for PHP extension mysqli.
* @see Database
*/
class DatabaseMysqli extends DatabaseMysqlBase {
- /** @var mysqli $mConn */
-
/**
* @param string $sql
- * @return resource
+ * @return mysqli_result
*/
protected function doQuery( $sql ) {
$conn = $this->getBindingHandle();
$mysqli = mysqli_init();
$connFlags = 0;
- if ( $this->mFlags & self::DBO_SSL ) {
+ if ( $this->flags & self::DBO_SSL ) {
$connFlags |= MYSQLI_CLIENT_SSL;
$mysqli->ssl_set(
$this->sslKeyPath,
$this->sslCiphers
);
}
- if ( $this->mFlags & self::DBO_COMPRESS ) {
+ if ( $this->flags & self::DBO_COMPRESS ) {
$connFlags |= MYSQLI_CLIENT_COMPRESS;
}
- if ( $this->mFlags & self::DBO_PERSISTENT ) {
+ if ( $this->flags & self::DBO_PERSISTENT ) {
$realServer = 'p:' . $realServer;
}
}
$mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
- if ( $mysqli->real_connect( $realServer, $this->mUser,
- $this->mPassword, $this->mDBname, $port, $socket, $connFlags )
+ if ( $mysqli->real_connect( $realServer, $this->user,
+ $this->password, $this->dbName, $port, $socket, $connFlags )
) {
return $mysqli;
}
* @return int
*/
function lastErrno() {
- if ( $this->mConn ) {
- return $this->mConn->errno;
+ if ( $this->conn instanceof mysqli ) {
+ return $this->conn->errno;
} else {
return mysqli_connect_errno();
}
/**
* @return int
*/
- function affectedRows() {
+ protected function fetchAffectedRowCount() {
$conn = $this->getBindingHandle();
return $conn->affected_rows;
function selectDB( $db ) {
$conn = $this->getBindingHandle();
- $this->mDBname = $db;
+ $this->dbName = $db;
return $conn->select_db( $db );
}
/**
* @param mysqli_result $res
- * @return bool
+ * @return stdClass|bool
*/
protected function mysqlFetchObject( $res ) {
$object = $res->fetch_object();
}
/**
- * @param mysqli $res
+ * @param mysqli_result $res
* @return mixed
*/
protected function mysqlNumFields( $res ) {
}
/**
- * @param mysqli $res
+ * @param mysqli_result $res
* @param int $n
* @return mixed
*/
}
/**
- * @param mysqli $res
+ * @param mysqli_result $res
* @param int $n
* @return mixed
*/
}
/**
- * @param mysqli $res
+ * @param mysqli_result $res
* @param int $n
* @return mixed
*/
protected function mysqlRealEscapeString( $s ) {
$conn = $this->getBindingHandle();
- return $conn->real_escape_string( $s );
+ return $conn->real_escape_string( (string)$s );
}
/**
* @return string
*/
public function __toString() {
- if ( $this->mConn instanceof mysqli ) {
- return (string)$this->mConn->thread_id;
+ if ( $this->conn instanceof mysqli ) {
+ return (string)$this->conn->thread_id;
} else {
// mConn might be false or something.
- return (string)$this->mConn;
+ return (string)$this->conn;
}
}
+
+ /**
+ * @return mysqli
+ */
+ protected function getBindingHandle() {
+ return parent::getBindingHandle();
+ }
}
class_alias( DatabaseMysqli::class, 'DatabaseMysqli' );