55 $qsByStatementId = [];
57 $conn = $this->getBindingHandle();
59 while ( $conn->more_results() && $conn->next_result() ) {
60 $mysqliResult = $conn->store_result();
61 $mysqliResult->free();
64 $combinedSql = implode(
";\n", $sqls );
66 AtEase::suppressWarnings();
67 $conn->multi_query( $combinedSql );
68 AtEase::restoreWarnings();
73 $mysqliResult = $conn->store_result();
74 $statementId = key( $sqls );
75 if ( $statementId !==
null ) {
77 if ( $mysqliResult ===
false ) {
78 $res = ( $conn->errno === 0 );
79 } elseif ( $mysqliResult instanceof mysqli_result ) {
80 $res =
new MysqliResultWrapper( $this, $mysqliResult );
84 $qsByStatementId[$statementId] =
new QueryStatus(
92 if ( $conn->more_results() ) {
99 while ( ( $statementId = key( $sqls ) ) !==
null ) {
100 $qsByStatementId[$statementId] =
new QueryStatus(
false, 0,
'Query aborted', 0 );
104 return $qsByStatementId;
116 if ( !function_exists(
'mysqli_init' ) ) {
117 throw $this->newExceptionAfterConnectError(
118 "MySQLi functions missing, have you compiled PHP with the --with-mysqli option?"
123 mysqli_report( MYSQLI_REPORT_OFF );
135 $hostAndPort = IPUtils::splitHostAndPort( $server );
136 if ( $hostAndPort ) {
137 $realServer = $hostAndPort[0];
138 if ( $hostAndPort[1] ) {
139 $port = $hostAndPort[1];
141 } elseif ( substr_count( $server,
':/' ) == 1 ) {
144 [ $realServer, $socket ] = explode(
':', $server, 2 );
146 $realServer = $server;
149 $mysqli = mysqli_init();
153 $flags = MYSQLI_CLIENT_FOUND_ROWS;
155 $flags |= MYSQLI_CLIENT_SSL;
164 if ( $this->getFlag( self::DBO_COMPRESS ) ) {
165 $flags |= MYSQLI_CLIENT_COMPRESS;
167 if ( $this->getFlag( self::DBO_PERSISTENT ) ) {
168 $realServer =
'p:' . $realServer;
171 if ( $this->utf8Mode ) {
174 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'utf8' );
176 $mysqli->options( MYSQLI_SET_CHARSET_NAME,
'binary' );
179 $mysqli->options( MYSQLI_OPT_CONNECT_TIMEOUT, $this->connectTimeout ?: 3 );
180 if ( $this->receiveTimeout ) {
181 $mysqli->options( MYSQLI_OPT_READ_TIMEOUT, $this->receiveTimeout );
185 $ok = $mysqli->real_connect( $realServer, $user, $password, $db, $port, $socket, $flags );
187 return $ok ? $mysqli :
null;