43 $ret = $conn->query( $sql );
45 $ret = $conn->query( $sql, MYSQLI_USE_RESULT );
59 # Avoid suppressed fatal error, which is very hard to track down
60 if ( !function_exists(
'mysqli_init' ) ) {
62 .
" have you compiled PHP with the --with-mysqli option?\n" );
72 $realServer = $hostAndPort[0];
73 if ( $hostAndPort[1] ) {
74 $port = $hostAndPort[1];
76 } elseif ( substr_count( $realServer,
':' ) == 1 ) {
79 $hostAndSocket = explode(
':', $realServer );
80 $realServer = $hostAndSocket[0];
81 $socket = $hostAndSocket[1];
85 if ( $this->mFlags &
DBO_SSL ) {
86 $connFlags |= MYSQLI_CLIENT_SSL;
89 $connFlags |= MYSQLI_CLIENT_COMPRESS;
92 $realServer =
'p:' . $realServer;
95 $mysqli = mysqli_init();
99 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'utf8' );
101 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'binary' );
103 $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
105 if ( $mysqli->real_connect( $realServer, $this->mUser,
106 $this->mPassword, $this->mDBname, $port, $socket, $connFlags )
126 if ( method_exists( $conn,
'set_charset' ) ) {
127 return $conn->set_charset( $charset );
129 return $this->
query(
'SET NAMES ' . $charset, __METHOD__ );
139 return $conn->close();
148 return (
int)$conn->insert_id;
155 if ( $this->mConn ) {
156 return $this->mConn->errno;
158 return mysqli_connect_errno();
168 return $conn->affected_rows;
178 $this->mDBname = $db;
180 return $conn->select_db( $db );
198 $object =
$res->fetch_object();
199 if ( $object === null ) {
211 $array =
$res->fetch_array();
212 if ( $array === null ) {
224 return $res->num_rows;
232 return $res->field_count;
241 $field =
$res->fetch_field_direct( $n );
245 $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
246 $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
247 $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
248 $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
249 $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
250 $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
251 $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
252 $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
253 $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
264 $field =
$res->fetch_field_direct( $n );
275 $field =
$res->fetch_field_direct( $n );
286 return $res->data_seek( $row );
294 if ( $conn === null ) {
295 return mysqli_connect_error();
309 return $conn->real_escape_string(
$s );
315 return $conn->ping();
325 if ( $this->mConn instanceof mysqli ) {
326 return (
string)$this->mConn->thread_id;
mysqlRealEscapeString($s)
Escapes special characters in a string for use in an SQL statement.
when a variable name is used in a it is silently declared as a new local masking the global
mysqlSetCharset($charset)
mysqlConnect($realServer)
bufferResults($buffer=null)
Turns buffering of SQL result sets on (true) or off (false).
__toString()
Give an id for the connection.
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
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.
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)
query($sql, $fname=__METHOD__, $tempIgnore=false)
Run an SQL query and return the result.
getBindingHandle()
Get the underlying binding handle, mConn.
$wgDBmysql5
Set to true to engage MySQL 4.1/5.0 charset-related features; for now will just cause sending of 'SET...