44 $ret = $conn->query(
$sql, MYSQLI_USE_RESULT );
56 # Avoid suppressed fatal error, which is very hard to track down
57 if ( !function_exists(
'mysqli_init' ) ) {
59 .
" have you compiled PHP with the --with-mysqli option?\n" );
69 $realServer = $hostAndPort[0];
70 if ( $hostAndPort[1] ) {
71 $port = $hostAndPort[1];
73 } elseif ( substr_count( $realServer,
':' ) == 1 ) {
76 $hostAndSocket = explode(
':', $realServer );
77 $realServer = $hostAndSocket[0];
78 $socket = $hostAndSocket[1];
81 $mysqli = mysqli_init();
85 $connFlags |= MYSQLI_CLIENT_SSL;
95 $connFlags |= MYSQLI_CLIENT_COMPRESS;
98 $realServer =
'p:' . $realServer;
101 if ( $this->utf8Mode ) {
104 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'utf8' );
106 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'binary' );
108 $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
110 if ( $mysqli->real_connect( $realServer, $this->mUser,
111 $this->mPassword, $this->mDBname, $port, $socket, $connFlags )
131 if ( method_exists( $conn,
'set_charset' ) ) {
132 return $conn->set_charset( $charset );
134 return $this->
query(
'SET NAMES ' . $charset, __METHOD__ );
144 return $conn->close();
153 return (
int)$conn->insert_id;
160 if ( $this->mConn ) {
161 return $this->mConn->errno;
163 return mysqli_connect_errno();
173 return $conn->affected_rows;
183 $this->mDBname = $db;
185 return $conn->select_db( $db );
203 $object =
$res->fetch_object();
204 if ( $object === null ) {
216 $array =
$res->fetch_array();
217 if ( $array === null ) {
229 return $res->num_rows;
237 return $res->field_count;
246 $field =
$res->fetch_field_direct( $n );
250 $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
251 $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
252 $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
253 $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
254 $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
255 $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
256 $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
257 $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
258 $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
269 $field =
$res->fetch_field_direct( $n );
280 $field =
$res->fetch_field_direct( $n );
291 return $res->data_seek( $row );
299 if ( $conn === null ) {
300 return mysqli_connect_error();
314 return $conn->real_escape_string(
$s );
324 if ( $this->mConn instanceof mysqli ) {
325 return (
string)$this->mConn->thread_id;
bufferResults($buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
mysqlRealEscapeString($s)
Escapes special characters in a string for use in an SQL statement.
mysqlSetCharset($charset)
mysqlConnect($realServer)
function doQuery $mConn $sql
mysqli
__toString()
Give an id for the connection.
static splitHostAndPort($both)
Given a host/port string, like one might find in the host part of a URL per RFC 2732, split the hostname part and the port part and return an array with an element for each.
getBindingHandle()
Get the underlying binding handle, mConn.
Database abstraction object for PHP extension mysqli.
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
mysqlDataSeek($res, $row)
Database abstraction object for MySQL.
mysqlFetchField($res, $n)
resource null $mConn
Database connection.
doQuery($sql)
The DBMS-dependent part of query()
query($sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.