47 $ret = $conn->query( $sql );
49 $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 );
82 $realServer = $hostAndSocket[0];
83 $socket = $hostAndSocket[1];
86 $mysqli = mysqli_init();
89 if ( $this->mFlags & self::DBO_SSL ) {
90 $connFlags |= MYSQLI_CLIENT_SSL;
99 if ( $this->mFlags & self::DBO_COMPRESS ) {
100 $connFlags |= MYSQLI_CLIENT_COMPRESS;
102 if ( $this->mFlags & 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( $realServer, $this->mUser,
116 $this->mPassword, $this->mDBname, $port, $socket, $connFlags )
136 if ( method_exists( $conn,
'set_charset' ) ) {
137 return $conn->set_charset( $charset );
139 return $this->
query(
'SET NAMES ' . $charset, __METHOD__ );
149 return $conn->close();
158 return (
int)$conn->insert_id;
165 if ( $this->mConn ) {
166 return $this->mConn->errno;
168 return mysqli_connect_errno();
178 return $conn->affected_rows;
188 $this->mDBname = $db;
190 return $conn->select_db( $db );
208 $object =
$res->fetch_object();
209 if ( $object ===
null ) {
221 $array =
$res->fetch_array();
222 if ( $array ===
null ) {
234 return $res->num_rows;
242 return $res->field_count;
251 $field =
$res->fetch_field_direct( $n );
255 $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
256 $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
257 $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
258 $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
259 $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
260 $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
261 $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
262 $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
263 $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
274 $field =
$res->fetch_field_direct( $n );
285 $field =
$res->fetch_field_direct( $n );
296 return $res->data_seek( $row );
304 if ( $conn ===
null ) {
305 return mysqli_connect_error();
319 return $conn->real_escape_string( (
string)
$s );
329 if ( $this->mConn instanceof mysqli ) {
330 return (
string)$this->mConn->thread_id;
338class_alias( DatabaseMysqli::class,
'DatabaseMysqli' );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
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,...
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
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php