48 $ret =
$conn->query( $sql, MYSQLI_USE_RESULT );
61 # Avoid suppressed fatal error, which is very hard to track down
62 if ( !function_exists(
'mysqli_init' ) ) {
64 .
" have you compiled PHP with the --with-mysqli option?\n" );
74 $realServer = $hostAndPort[0];
75 if ( $hostAndPort[1] ) {
76 $port = $hostAndPort[1];
78 } elseif ( substr_count( $realServer,
':' ) == 1 ) {
81 $hostAndSocket = explode(
':', $realServer, 2 );
82 $realServer = $hostAndSocket[0];
83 $socket = $hostAndSocket[1];
86 $mysqli = mysqli_init();
89 if ( $this->flags & self::DBO_SSL ) {
90 $connFlags |= MYSQLI_CLIENT_SSL;
99 if ( $this->flags & self::DBO_COMPRESS ) {
100 $connFlags |= MYSQLI_CLIENT_COMPRESS;
102 if ( $this->flags & self::DBO_PERSISTENT ) {
103 $realServer =
'p:' . $realServer;
106 if ( $this->utf8Mode ) {
109 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'utf8' );
111 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'binary' );
113 $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
115 if ( $mysqli->real_connect(
142 if ( method_exists(
$conn,
'set_charset' ) ) {
143 return $conn->set_charset( $charset );
145 return $this->
query(
'SET NAMES ' . $charset, __METHOD__ );
155 return $conn->close();
164 return (
int)
$conn->insert_id;
171 if ( $this->conn instanceof mysqli ) {
172 return $this->conn->errno;
174 return mysqli_connect_errno();
184 return $conn->affected_rows;
191 throw new DBExpectedError( $this, __CLASS__ .
": domain schemas are not supported." );
195 if ( !
$conn->select_db( $database ) ) {
196 throw new DBExpectedError( $this,
"Could not select database '$database'." );
200 $this->currentDomain = $domain;
220 $object =
$res->fetch_object();
221 if ( $object ===
null ) {
233 $array =
$res->fetch_array();
234 if ( $array ===
null ) {
246 return $res->num_rows;
254 return $res->field_count;
263 $field =
$res->fetch_field_direct( $n );
267 $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
268 $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
269 $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
270 $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
271 $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
272 $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
273 $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
274 $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
275 $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
286 $field =
$res->fetch_field_direct( $n );
297 $field =
$res->fetch_field_direct( $n );
308 return $res->data_seek( $row );
316 if (
$conn ===
null ) {
317 return mysqli_connect_error();
331 return $conn->real_escape_string( (
string)
$s );
341 if ( $this->conn instanceof mysqli ) {
342 return (
string)$this->conn->thread_id;
353 return parent::getBindingHandle();
360class_alias( DatabaseMysqli::class,
'DatabaseMysqli' );
A collection of public static functions to play with IP address and IP ranges.
static splitHostAndPort( $both)
Given a host/port string, like one might find in the host part of a URL per RFC 2732,...
Class to handle database/prefix specification for IDatabase domains.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret