29 use Wikimedia\AtEase\AtEase;
45 AtEase::suppressWarnings();
47 AtEase::restoreWarnings();
59 if ( !function_exists(
'mysqli_init' ) ) {
61 "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
77 $realServer = $hostAndPort[0];
78 if ( $hostAndPort[1] ) {
79 $port = $hostAndPort[1];
81 } elseif ( substr_count( $realServer,
':/' ) == 1 ) {
84 list( $realServer, $socket ) = explode(
':', $realServer, 2 );
87 $mysqli = mysqli_init();
91 $connFlags = MYSQLI_CLIENT_FOUND_ROWS;
93 $connFlags |= MYSQLI_CLIENT_SSL;
103 $connFlags |= MYSQLI_CLIENT_COMPRESS;
106 $realServer =
'p:' . $realServer;
109 if ( $this->utf8Mode ) {
112 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'utf8' );
114 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'binary' );
116 $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
118 if ( $mysqli->real_connect(
139 return $conn->close();
148 return (
int)
$conn->insert_id;
155 if ( $this->conn instanceof mysqli ) {
156 return $this->conn->errno;
158 return mysqli_connect_errno();
168 return $conn->affected_rows;
186 $object =
$res->fetch_object();
187 if ( $object ===
null ) {
199 $array =
$res->fetch_array();
200 if ( $array ===
null ) {
212 return $res->num_rows;
220 return $res->field_count;
229 $field =
$res->fetch_field_direct( $n );
233 $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
234 $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
235 $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
236 $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
237 $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
238 $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
239 $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
240 $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
241 $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
252 $field =
$res->fetch_field_direct( $n );
263 $field =
$res->fetch_field_direct( $n );
274 return $res->data_seek( $row );
282 if (
$conn ===
null ) {
283 return mysqli_connect_error();
297 return $conn->real_escape_string( (
string)
$s );
304 return parent::getBindingHandle();
311 class_alias( DatabaseMysqli::class,
'DatabaseMysqli' );