%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 3.15.218.169 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/db/ |
Upload File : |
<?php namespace Bitrix\Main\DB; use Bitrix\Main\Diag; class MysqlConnection extends MysqlCommonConnection { /********************************************************** * SqlHelper **********************************************************/ /** * @inheritDoc */ protected function createSqlHelper() { return new MysqlSqlHelper($this); } /*********************************************************** * Connection and disconnection ***********************************************************/ /** * Establishes a connection to the database. * Includes php_interface/after_connect_d7.php on success. * Throws exception on failure. * * @return void * @throws \Bitrix\Main\DB\ConnectionException */ protected function connectInternal() { if($this->isConnected) { return; } if(($this->options & self::PERSISTENT) != 0) { $connection = mysql_pconnect($this->host, $this->login, $this->password); } else { $connection = mysql_connect($this->host, $this->login, $this->password, true); } if(!$connection) { throw new ConnectionException('Mysql connect error ['.$this->host.', '.gethostbyname($this->host).']', mysql_error()); } if($this->database !== null) { if(!mysql_select_db($this->database, $connection)) { throw new ConnectionException('Mysql select db error ['.$this->database.']', mysql_error($connection)); } } $this->resource = $connection; $this->isConnected = true; $this->afterConnected(); } /** * Disconnects from the database. * Does nothing if there was no connection established. * * @return void */ public function disconnectInternal() { if (!$this->isConnected) return; mysql_close($this->resource); $this->isConnected = false; } /********************************************************* * Query *********************************************************/ /** * @inheritDoc */ protected function queryInternal($sql, array $binds = null, \Bitrix\Main\Diag\SqlTrackerQuery $trackerQuery = null) { $this->connectInternal(); if ($trackerQuery != null) $trackerQuery->startQuery($sql, $binds); $result = mysql_query($sql, $this->resource); if ($trackerQuery != null) $trackerQuery->finishQuery(); $this->lastQueryResult = $result; if (!$result) throw new SqlQueryException('Mysql query error', mysql_error($this->resource), $sql); return $result; } /** * @inheritDoc */ protected function createResult($result, \Bitrix\Main\Diag\SqlTrackerQuery $trackerQuery = null) { return new MysqlResult($result, $this, $trackerQuery); } /** * @inheritDoc */ public function getInsertedId() { $this->connectInternal(); return mysql_insert_id($this->resource); } /** * @inheritDoc */ public function getAffectedRowsCount() { return mysql_affected_rows($this->getResource()); } /********************************************************* * Type, version, cache, etc. *********************************************************/ /** * @inheritDoc */ public function getVersion() { if ($this->version == null) { $version = $this->queryScalar("SELECT VERSION()"); if ($version != null) { $version = trim($version); preg_match("#[0-9]+\\.[0-9]+\\.[0-9]+#", $version, $ar); $this->version = $ar[0]; } } return array($this->version, null); } /** * @inheritDoc */ protected function getErrorMessage() { return sprintf("[%s] %s", mysql_errno($this->resource), mysql_error($this->resource)); } /** * Selects the default database for database queries. * * @param string $database Database name. * @return bool */ public function selectDatabase($database) { return mysql_select_db($database, $this->resource); } }