Move up devunt's name to Developers
[lhc/web/wiklou.git] / includes / db / DatabaseMysqli.php
index 2ce6307..d2b5ecb 100644 (file)
@@ -58,14 +58,22 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                }
 
                // Other than mysql_connect, mysqli_real_connect expects an explicit port
-               // parameter. So we need to parse the port out of $realServer
+               // and socket parameters. So we need to parse the port and socket out of
+               // $realServer
                $port = null;
+               $socket = null;
                $hostAndPort = IP::splitHostAndPort( $realServer );
                if ( $hostAndPort ) {
                        $realServer = $hostAndPort[0];
                        if ( $hostAndPort[1] ) {
                                $port = $hostAndPort[1];
                        }
+               } elseif ( substr_count( $realServer, ':' ) == 1 ) {
+                       // If we have a colon and something that's not a port number
+                       // inside the hostname, assume it's the socket location
+                       $hostAndSocket = explode( ':', $realServer );
+                       $realServer = $hostAndSocket[0];
+                       $socket = $hostAndSocket[1];
                }
 
                $connFlags = 0;
@@ -90,7 +98,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, 3 );
 
                if ( $mysqli->real_connect( $realServer, $this->mUser,
-                       $this->mPassword, $this->mDBname, $port, null, $connFlags )
+                       $this->mPassword, $this->mDBname, $port, $socket, $connFlags )
                ) {
                        return $mysqli;
                }
@@ -126,7 +134,7 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         * @return int
         */
        function insertId() {
-               return $this->mConn->insert_id;
+               return (int)$this->mConn->insert_id;
        }
 
        /**
@@ -157,13 +165,6 @@ class DatabaseMysqli extends DatabaseMysqlBase {
                return $this->mConn->select_db( $db );
        }
 
-       /**
-        * @return string
-        */
-       function getServerVersion() {
-               return $this->mConn->server_info;
-       }
-
        /**
         * @param mysqli $res
         * @return bool
@@ -223,11 +224,18 @@ class DatabaseMysqli extends DatabaseMysqlBase {
         */
        protected function mysqlFetchField( $res, $n ) {
                $field = $res->fetch_field_direct( $n );
+
+               // Add missing properties to result (using flags property)
+               // which will be part of function mysql-fetch-field for backward compatibility
                $field->not_null = $field->flags & MYSQLI_NOT_NULL_FLAG;
                $field->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG;
                $field->unique_key = $field->flags & MYSQLI_UNIQUE_KEY_FLAG;
                $field->multiple_key = $field->flags & MYSQLI_MULTIPLE_KEY_FLAG;
                $field->binary = $field->flags & MYSQLI_BINARY_FLAG;
+               $field->numeric = $field->flags & MYSQLI_NUM_FLAG;
+               $field->blob = $field->flags & MYSQLI_BLOB_FLAG;
+               $field->unsigned = $field->flags & MYSQLI_UNSIGNED_FLAG;
+               $field->zerofill = $field->flags & MYSQLI_ZEROFILL_FLAG;
 
                return $field;
        }