51 if (($pos = strpos($host,
":")) !==
false)
53 $port = intval(substr($host, $pos + 1));
54 $host = substr($host, 0, $pos);
56 if (($this->options & self::PERSISTENT) != 0)
61 $connection = \mysqli_init();
67 if (!empty($this->initCommand))
69 if (!$connection->options(MYSQLI_INIT_COMMAND, $this->initCommand))
77 $success = $connection->real_connect($host, $this->login, $this->password, $this->database, $port);
81 $success = $connection->real_connect($host, $this->login, $this->password, $this->database);
87 'Mysql connect error ['.$this->host.
']',
88 sprintf(
'(%s) %s', $connection->connect_errno, $connection->connect_error)
92 $this->resource = $connection;
95 if (isset($this->configuration[
'charset']))
97 $connection->set_charset($this->configuration[
'charset']);
101 if (isset($this->configuration[
'memcache']))
103 if (function_exists(
'mysqlnd_memcache_set'))
105 $memcached = \Bitrix\Main\Application::getInstance()->getConnectionPool()->getConnection($this->configuration[
'memcache']);
106 mysqlnd_memcache_set($this->resource, $memcached->getResource());
110 $this->afterConnected();