Example #1
0
 /**
  * Constructor
  *
  * @param string $dsn
  * @param string $username
  * @param string $passwd
  * @param array $options
  * @return void
  */
 public function __construct($dsn, $username = null, $password = null, array $options = array())
 {
     //Parse the DSN
     $parsedDsn = self::parseDsn($dsn, array('charset'));
     //Get SID name
     $sidString = isset($parsedDsn['sid']) ? '(SID = ' . $parsedDsn['sid'] . ')' : '';
     //Create a description to locate the database to connect to
     $description = '(DESCRIPTION =
         (ADDRESS_LIST =
             (ADDRESS = (PROTOCOL = TCP)(HOST = ' . $parsedDsn['hostname'] . ')
             (PORT = ' . $parsedDsn['port'] . '))
         )
         (CONNECT_DATA =
                 ' . $sidString . '
                 (SERVICE_NAME = ' . $parsedDsn['dbname'] . ')
         )
     )';
     //Attempt a connection
     if (isset($options[\PDO::ATTR_PERSISTENT]) && $options[\PDO::ATTR_PERSISTENT]) {
         $this->_dbh = @oci_pconnect($username, $password, $description, $parsedDsn['charset']);
     } else {
         $this->_dbh = @oci_connect($username, $password, $description, $parsedDsn['charset']);
     }
     //Check if connection was successful
     if (!$this->_dbh) {
         $e = oci_error();
         throw new \PDOException($e['message']);
     }
     //Save the options
     $this->_options = $options;
 }
 function connect()
 {
     if (0 == $this->Link_ID) {
         if ($this->Debug) {
             printf("<br>Connecting to {$this->Database}%s...<br>\n", $this->Host ? " ({$this->Host})" : "");
         }
         if ($this->share_connections) {
             if (!$this->share_connection_name) {
                 $this->share_connection_name = get_class($this) . "_Link_ID";
             } else {
                 $this->share_connection_name .= "_Link_ID";
             }
             global ${$this->share_connection_name};
             if (${$this->share_connection_name}) {
                 $this->Link_ID = ${$this->share_connection_name};
                 return true;
             }
         }
         if ($this->persistent) {
             $this->Link_ID = oci_pconnect($this->User, $this->Password, $this->Host ? sprintf($this->full_connection_string, $this->Host, $this->Port, $this->Database) : $this->Database, 'AL32UTF8');
         } else {
             $this->Link_ID = oci_connect($this->User, $this->Password, $this->Host ? sprintf($this->full_connection_string, $this->Host, $this->Port, $this->Database) : $this->Database, 'AL32UTF8');
         }
         if (!$this->Link_ID) {
             $this->connect_failed();
             return false;
         }
         if ($this->share_connections) {
             ${$this->share_connection_name} = $this->Link_ID;
         }
         if ($this->Debug) {
             printf("<br>Obtained the Link_ID: {$this->Link_ID}<br>\n");
         }
     }
 }
Example #3
0
File: PDO.php Project: taq/pdooci
 /**
  * Class constructor
  *
  * @param string $data     the connection string
  * @param string $username user name
  * @param string $password password
  * @param string $options  options to send to the connection
  *
  * @return \PDO object
  * @throws \PDOException
  */
 public function __construct($data, $username, $password, $options = null)
 {
     if (!function_exists("\\oci_parse")) {
         throw new \PDOException("No support for Oracle, please install the OCI driver");
     }
     // find charset
     $charset = null;
     $data = preg_replace('/^oci:/', '', $data);
     $tokens = preg_split('/;/', $data);
     $data = str_replace(array('dbname=//', 'dbname='), '', $tokens[0]);
     $charset = $this->_getCharset($tokens);
     try {
         if (!is_null($options) && array_key_exists(\PDO::ATTR_PERSISTENT, $options)) {
             $this->_con = \oci_pconnect($username, $password, $data, $charset);
             $this->setError();
         } else {
             $this->_con = \oci_connect($username, $password, $data, $charset);
             $this->setError();
         }
         if (!$this->_con) {
             $error = oci_error();
             throw new \Exception($error['code'] . ': ' . $error['message']);
         }
     } catch (\Exception $exception) {
         throw new \PDOException($exception->getMessage());
     }
     return $this;
 }
Example #4
0
 public static function connection($dsn_data)
 {
     if (!isset($dsn_data['DB_HOST']) || empty($dsn_data['DB_HOST'])) {
         throw new KurogoConfigurationException("Oracle host not specified");
     }
     if (!isset($dsn_data['DB_USER']) || empty($dsn_data['DB_USER'])) {
         throw new KurogoConfigurationException("Oracle user not specified");
     }
     if (!isset($dsn_data['DB_PASS']) || empty($dsn_data['DB_PASS'])) {
         throw new KurogoConfigurationException("Oracle password not specified");
     }
     if (!isset($dsn_data['DB_DBNAME']) || empty($dsn_data['DB_DBNAME'])) {
         throw new KurogoConfigurationException("Oracle database not specified");
     }
     $connectionString = $dsn_data['DB_HOST'];
     if (isset($dsn_data['DB_PORT']) && !empty($dsn_data['DB_PORT'])) {
         $connectionString .= ':' . $dsn_data['DB_PORT'];
     }
     $connectionString .= '/' . $dsn_data['DB_DBNAME'];
     if (isset($dsn_data['DB_CHARSET']) && !empty($dsn_data['DB_CHARSET'])) {
         $charSet = $dsn_data['DB_CHARSET'];
     } else {
         $charSet = 'utf8';
     }
     $connection = oci_pconnect($dsn_data['DB_USER'], $dsn_data['DB_PASS'], $connectionString, $charSet);
     return $connection;
 }
Example #5
0
 /**
  * Connect to an Oracle database using a persistent connection
  *
  * New instances of this class will use the same connection across multiple requests.
  *
  * @param string $username
  * @param string $password
  * @param string $connectionString
  * @param string $characterSet
  * @param int $sessionMode
  * @return resource
  * @see http://php.net/manual/en/function.oci-pconnect.php
  */
 protected function connect($username, $password, $connectionString = null, $characterSet = null, $sessionMode = null)
 {
     set_error_handler($this->getErrorHandler());
     $connection = oci_pconnect($username, $password, $connectionString, $characterSet, $sessionMode);
     restore_error_handler();
     return $connection;
 }
Example #6
0
 /**
  * Class constructor
  *
  * @param                 $data
  * @param                 $username
  * @param                 $password
  * @param array           $options
  * @param AbstractLogger $logger
  * @param CacheInterface   $cache
  */
 public function __construct($data, $username = null, $password = null, $options = [], AbstractLogger $logger = null, CacheInterface $cache = null)
 {
     if (!function_exists("\\oci_parse")) {
         throw new PDOException(PHP_VERSION . " : No support for Oracle, please install the OCI driver");
     }
     // find charset
     $charset = null;
     $data = preg_replace('/^oci:/', '', $data);
     $tokens = preg_split('/;/', $data);
     $data = $tokens[0];
     $charset = $this->_getCharset($tokens);
     try {
         if (!is_null($options) && array_key_exists(\PDO::ATTR_PERSISTENT, $options)) {
             $this->_con = \oci_pconnect($username, $password, $data, $charset);
             $this->setError();
         } else {
             $this->_con = \oci_connect($username, $password, $data, $charset);
             $this->setError();
         }
         if (!$this->_con) {
             $error = oci_error();
             throw new \Exception($error['code'] . ': ' . $error['message']);
         }
     } catch (\Exception $exception) {
         throw new PDOException($exception->getMessage());
     }
     $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
     $this->setConfig($options, $data);
     $this->setLogger($logger ? $logger : new NullLogger());
     $this->setCache($cache ? $cache : new NullCache());
 }
Example #7
0
 /**
  * Connect to database server and select database
  */
 protected function connect()
 {
     if ($GLOBALS['TL_CONFIG']['dbPconnect']) {
         $this->resConnection = @oci_pconnect($GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass'], '', $GLOBALS['TL_CONFIG']['dbCharset']);
     } else {
         $this->resConnection = @oci_connect($GLOBALS['TL_CONFIG']['dbUser'], $GLOBALS['TL_CONFIG']['dbPass'], '', $GLOBALS['TL_CONFIG']['dbCharset']);
     }
 }
 /** 
  * DB接続
  * 
  * @access	public
  * @return	object	$db	接続ID
  */
 private function connect()
 {
     $dateTime = date("Y-m-d H:i:s");
     $this->conn = oci_pconnect($this->INI_DATA['database_user'], $this->INI_DATA['database_password'], ($this->INI_DATA['database_host'] ? $this->INI_DATA['database_host'] . "/" : "") . $this->INI_DATA['database_name']);
     if (!$this->conn) {
         $this->dbError("{$dateTime} <connect error> {$this->conn}");
     }
 }
Example #9
0
 public function getOraclePConnection()
 {
     $conn = oci_pconnect($this->username, $this->password, $this->host, $this->charset);
     if (!$conn) {
         $e = oci_error();
         trigger_error(htmlentities($e['message']), E_USER_ERROR);
     }
     return $conn;
 }
Example #10
0
 public function connect()
 {
     $conf = c("db.write");
     $conn_str = sprintf("(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = %s)(PORT = %s)) (CONNECT_DATA= (SID = %s)))", $conf['dbhost'], $conf['dbport'], $conf['dbname']);
     self::$link = oci_pconnect($con_user, $con_pwd, $conn_str, str_replace("-", "", $con_charset));
     if (!self::$link) {
         throw_exception(oci_error());
     }
 }
 /**
  * Creates a Connection to an Oracle Database using oci8 extension.
  *
  * @param string      $username
  * @param string      $password
  * @param string      $db
  * @param string|null $charset
  * @param integer     $sessionMode
  * @param boolean     $persistent
  *
  * @throws OCI8Exception
  */
 public function __construct($username, $password, $db, $charset = null, $sessionMode = OCI_DEFAULT, $persistent = false)
 {
     if (!defined('OCI_NO_AUTO_COMMIT')) {
         define('OCI_NO_AUTO_COMMIT', 0);
     }
     $this->dbh = $persistent ? @oci_pconnect($username, $password, $db, $charset, $sessionMode) : @oci_connect($username, $password, $db, $charset, $sessionMode);
     if (!$this->dbh) {
         throw OCI8Exception::fromErrorInfo(oci_error());
     }
 }
 protected function connect()
 {
     if ($this->lid == 0) {
         $charset = SITE_DB_CHARSET == 'cp1251' ? 'CL8MSWIN1251' : 'AL32UTF8';
         $this->lid = @oci_pconnect(SITE_DB_USER, SITE_DB_PASSWORD, SITE_DB_HOST, $charset);
         if (!$this->lid) {
             throw new Exception("Couldn't connect to server " . SITE_DB_HOST);
         }
         //if
     }
 }
Example #13
0
 public function connect($config = [])
 {
     $this->config = $config;
     $dsn = !empty($this->config['dsn']) ? $this->config['dsn'] : $this->config['host'];
     if ($this->config['pconnect'] === true) {
         $this->connect = empty($this->config['charset']) ? @oci_pconnect($this->config['user'], $this->config['password'], $dsn) : @oci_pconnect($this->config['user'], $this->config['password'], $dsn, $this->config['charset']);
     } else {
         $this->connect = empty($this->config['charset']) ? @oci_connect($this->config['user'], $this->config['password'], $dsn) : @oci_connect($this->config['user'], $this->config['password'], $dsn, $this->config['charset']);
     }
     if (empty($this->connect)) {
         die(getErrorMessage('Database', 'connectError'));
     }
 }
Example #14
0
 /**
  * Constructor opens a connection to the database
  * @param string $module Module text for End-to-End Application Tracing
  * @param string $cid Client Identifier for End-to-End Application Tracing
  */
 function __construct($module, $cid)
 {
     $this->conn = @oci_pconnect(SCHEMA, PASSWORD, DATABASE, CHARSET);
     if (!$this->conn) {
         $m = oci_error();
         throw new \Exception('No se puede conectar a la base de datos: ' . $m['message']);
     }
     // Record the "name" of the web user, the client info and the module.
     // These are used for end-to-end tracing in the DB.
     oci_set_client_info($this->conn, CLIENT_INFO);
     oci_set_module_name($this->conn, $module);
     oci_set_client_identifier($this->conn, $cid);
 }
Example #15
0
 protected function connect()
 {
     if ($this->lnk === null) {
         $this->lnk = $this->settings->persist ? @oci_pconnect($this->settings->username, $this->settings->password, $this->settings->servername, $this->settings->charset) : @oci_connect($this->settings->username, $this->settings->password, $this->settings->servername, $this->settings->charset);
         if ($this->lnk === false) {
             throw new DatabaseException('Connect error');
         }
         $this->real("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
         if ($this->settings->timezone) {
             $this->real("ALTER session SET time_zone = '" . addslashes($this->settings->timezone) . "'");
         }
     }
 }
Example #16
0
 /**
  * Make a Connect to the oracle Server
  *
  * @param string $host
  * @param string $user
  * @param string $pass
  * @param string $db
  * @param string $schema optional
  * @param string $enconding optional
  * @return mixed return connection resource
  */
 function connect($host, $user, $pass, $db, $schema = "", $encoding = "")
 {
     if ($this->CLASS['config']->db->pconnect) {
         $this->connection = oci_pconnect($user, $pass, $db, $encoding);
     } else {
         $this->connection = oci_connect($user, $pass, $db, $encoding);
     }
     if (!$this->connection) {
         $this->CLASS['error']->log("Cannnot connect to host!", 1, "class-oracle.php::connect");
         exit;
     }
     return $this->connection;
 }
 public function Connect($host, $user, $pass, $mode = OCI_DEFAULT, $type = ORA_CONNECTION_TYPE_DEFAULT)
 {
     switch ($type) {
         case ORA_CONNECTION_TYPE_PERSISTENT:
             $this->conn_handle = oci_pconnect($user, $pass, $host, $this->charset, $mode);
             break;
         case ORA_CONNECTION_TYPE_NEW:
             $this->conn_handle = oci_new_connect($user, $pass, $host, $this->charset, $mode);
             break;
         default:
             $this->conn_handle = oci_connect($user, $pass, $host, $this->charset, $mode);
     }
     return is_resource($this->conn_handle) ? true : false;
 }
Example #18
0
 /**
  * Constructor
  *
  * @param string $dsn
  * @param string $username
  * @param string $passwd
  * @param array $options
  * @return void
  */
 public function __construct($dsn, $username = null, $password = null, array $options = array())
 {
     $parsedDsn = Pdo_Util::parseDsn($dsn, array('dbname', 'charset'));
     if (isset($options[PDO::ATTR_PERSISTENT]) && $options[PDO::ATTR_PERSISTENT]) {
         $this->_dbh = @oci_pconnect($username, $password, $parsedDsn['dbname'], $parsedDsn['charset']);
     } else {
         $this->_dbh = @oci_connect($username, $password, $parsedDsn['dbname'], $parsedDsn['charset']);
     }
     if (!$this->_dbh) {
         $e = oci_error();
         throw new PDOException($e['message']);
     }
     $this->_options = $options;
 }
 /**
  * Connects to the database.
  *
  * @return void
  * @throw eZClusterHandlerDBNoConnectionException
  * @throw eZClusterHandlerDBNoDatabaseException
  **/
 public function _connect()
 {
     if (!function_exists('oci_connect')) {
         throw new eZClusterHandlerDBNoDatabaseException("PECL oci8 extension (http://pecl.php.net/package/oci8) is required to use Oracle clustering functionality.");
     }
     // DB Connection setup
     // This part is not actually required since _connect will only be called
     // once, but it is useful to run the unit tests. So be it.
     // @todo refactor this using eZINI::setVariable in unit tests
     if (self::$dbparams === null) {
         $siteINI = eZINI::instance('site.ini');
         $fileINI = eZINI::instance('file.ini');
         self::$dbparams = array();
         //self::$dbparams['host']       = $fileINI->variable( 'eZDFSClusteringSettings', 'DBHost' );
         //self::$dbparams['port']       = $fileINI->variable( 'eZDFSClusteringSettings', 'DBPort' );
         //self::$dbparams['socket']     = $fileINI->variable( 'eZDFSClusteringSettings', 'DBSocket' );
         self::$dbparams['dbname'] = $fileINI->variable('eZDFSClusteringSettings', 'DBName');
         self::$dbparams['user'] = $fileINI->variable('eZDFSClusteringSettings', 'DBUser');
         self::$dbparams['pass'] = $fileINI->variable('eZDFSClusteringSettings', 'DBPassword');
         self::$dbparams['max_connect_tries'] = $fileINI->variable('eZDFSClusteringSettings', 'DBConnectRetries');
         self::$dbparams['max_execute_tries'] = $fileINI->variable('eZDFSClusteringSettings', 'DBExecuteRetries');
         self::$dbparams['sql_output'] = $siteINI->variable("DatabaseSettings", "SQLOutput") == "enabled";
         self::$dbparams['cache_generation_timeout'] = $siteINI->variable("ContentSettings", "CacheGenerationTimeout");
         self::$dbparams['persistent_connection'] = $fileINI->hasVariable('eZDFSClusteringSettings', 'DBPersistentConnection') ? $fileINI->variable('eZDFSClusteringSettings', 'DBPersistentConnection') == 'enabled' : false;
     }
     $maxTries = self::$dbparams['max_connect_tries'];
     $tries = 0;
     eZPerfLogger::accumulatorStart('oracle_cluster_connect', 'Oracle Cluster', 'Cluster database connection');
     while ($tries < $maxTries) {
         if (self::$dbparams['persistent_connection']) {
             if ($this->db = oci_pconnect(self::$dbparams['user'], self::$dbparams['pass'], self::$dbparams['dbname'])) {
                 break;
             }
         } else {
             if ($this->db = oci_connect(self::$dbparams['user'], self::$dbparams['pass'], self::$dbparams['dbname'])) {
                 break;
             }
         }
         ++$tries;
     }
     eZPerfLogger::accumulatorStop('oracle_cluster_connect');
     if (!$this->db) {
         throw new eZClusterHandlerDBNoConnectionException(self::$dbparams['dbname'], self::$dbparams['user'], self::$dbparams['pass']);
     }
     // DFS setup
     if ($this->dfsbackend === null) {
         $this->dfsbackend = new eZDFSFileHandlerTracing50DFSBackend();
     }
 }
 /**
  * Creates a Connection to an Oracle Database using oci8 extension.
  *
  * @param string $dsn Oracle connection string in oci_connect format.
  * @param string $username Oracle username.
  * @param string $password Oracle user's password.
  * @param array $options Additional connection settings.
  *
  * @throws OCI8Exception
  */
 public function __construct($dsn, $username, $password, $options)
 {
     $persistent = !empty($options['persistent']);
     $charset = !empty($options['charset']) ? $options['charset'] : null;
     $sessionMode = !empty($options['sessionMode']) ? $options['sessionMode'] : null;
     if ($persistent) {
         $this->dbh = @oci_pconnect($username, $password, $dsn, $charset, $sessionMode);
     } else {
         $this->dbh = @oci_connect($username, $password, $dsn, $charset, $sessionMode);
     }
     if (!$this->dbh) {
         throw OCI8Exception::fromErrorInfo(oci_error());
     }
     $this->config($options);
 }
Example #21
0
 public function __construct($dsn, $username, $password, $options)
 {
     $persistent = false;
     $db = substr($dsn, strpos($dsn, 'dbname=') + 7);
     $charset = null;
     $sessionMode = null;
     if (!defined('OCI_NO_AUTO_COMMIT')) {
         define('OCI_NO_AUTO_COMMIT', 0);
     }
     $this->dbh = $persistent ? @oci_pconnect($username, $password, $db, $charset, $sessionMode) : @oci_connect($username, $password, $db, $charset, $sessionMode);
     if (!$this->dbh) {
         $error = oci_error();
         throw new \Exception($error['message'], $error['code']);
     }
 }
Example #22
0
function dbQuery($query, $show_errors = true, $all_results = true, $show_output = true)
{
    if ($show_errors) {
        error_reporting(E_ALL);
    } else {
        error_reporting(E_PARSE);
    }
    // Connect to the Oracle database management system
    $link = oci_pconnect('SCOTT', 'testpass', '//localhost/XE');
    if (!$link) {
        die(oci_error());
    }
    // Print results in HTML
    print "<html><body>\n";
    // Print SQL query to test sqlmap '--string' command line option
    //print "<b>SQL query:</b> " . $query . "<br>\n";
    // Perform SQL injection affected query
    $stid = oci_parse($link, $query);
    if (!$stid) {
        $e = oci_error($link);
        die(htmlentities($e['message']));
    }
    $result = oci_execute($stid, OCI_DEFAULT);
    if (!$result) {
        if ($show_errors) {
            $e = oci_error($stid);
            print "<b>SQL error:</b> " . $e['message'] . "<br>\n";
        }
        exit(1);
    }
    if (!$show_output) {
        exit(1);
    }
    print "<b>SQL results:</b>\n";
    print "<table border=\"1\">\n";
    while ($line = oci_fetch_array($stid, OCI_ASSOC)) {
        print "<tr>";
        foreach ($line as $col_value) {
            print "<td>" . $col_value . "</td>";
        }
        print "</tr>\n";
        if (!$all_results) {
            break;
        }
    }
    print "</table>\n";
    print "</body></html>";
}
Example #23
0
 /**
  * Creates a PDO instance representing a connection to a database
  *
  * @param string $dsn The Data Source Name, or DSN, contains the information required to connect to the database.
  * @param string $username The user name for the DSN string.
  * @param string $password The password for the DSN string.
  * @param array $options A key=>value array of driver-specific connection options.
  */
 public function __construct($dsn, $username = null, $password = null, array $options = [])
 {
     $parsedDsn = Oci8\Util::parseDsn($dsn, ['dbname', 'charset']);
     $this->setAttribute(PDO::ATTR_CLIENT_VERSION, oci_client_version());
     // can't do a simple array_merge because keys are numeric
     foreach ($options as $option => $value) {
         $this->setAttribute($option, $value);
     }
     if ($this->getAttribute(PDO::ATTR_PERSISTENT)) {
         $this->dbh = oci_pconnect($username, $password, $parsedDsn['dbname'], $parsedDsn['charset']);
     } else {
         $this->dbh = oci_connect($username, $password, $parsedDsn['dbname'], $parsedDsn['charset']);
     }
     if ($this->dbh === false) {
         $this->handleError($this->error = oci_error());
     }
 }
 /**
 * connect
 +-----------------------------------------
 * @access public
 * @return void
 */
 public function connect()
 {
     $sn = ($this->host ? '//' . $this->host . ':' . $this->port . '/' : '') . $this->sid;
     if (!$this->persistent) {
         $this->_connect = oci_connect($this->username, $this->password, $sn, $this->charset);
     } else {
         $this->_connect = oci_pconnect($this->username, $this->password, $sn, $this->charset);
     }
     if ($this->_connect) {
         debug::log("PDO: DB connection is active({$this->dsn}).");
         $this->_active = true;
     } else {
         $e = oci_error();
         error_handler($e['code'], $e['message'], __FILE__, __LINE__);
     }
     return $this->_connect;
 }
Example #25
0
 /**
  * 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 = oci_pconnect($this->login, $this->password, $this->database);
     } else {
         $connection = oci_new_connect($this->login, $this->password, $this->database);
     }
     if (!$connection) {
         throw new ConnectionException('Oracle connect error', $this->getErrorMessage());
     }
     $this->isConnected = true;
     $this->resource = $connection;
     $this->afterConnected();
 }
Example #26
0
 /**
  * Constructor.
  *
  * @param string $dsn DSN string to connect to database
  * @param string $username Username of creditial to login to database
  * @param string $password Password of creditial to login to database
  * @param array $driver_options Options for the connection handle
  * @param string $charset Character set to specify to the database when connecting
  *
  * @throws OCIException if connection fails
  */
 public function __construct($dsn, $username, $password, $driver_options = [], $charset = '')
 {
     $this->dsn = $dsn;
     $this->username = $username;
     $this->password = $password;
     $this->attributes = $driver_options + $this->attributes;
     $this->charset = $charset;
     if ($this->getAttribute(\PDO::ATTR_PERSISTENT)) {
         $this->conn = oci_pconnect($username, $password, $dsn, $charset);
     } else {
         $this->conn = oci_connect($username, $password, $dsn, $charset);
     }
     //Check if connection was successful
     if (!$this->conn) {
         throw new OCIException($this->setErrorInfo('08006'));
     }
 }
Example #27
0
function PMA_DBI_real_connect($server, $user, $password, $client_flags, $persistant = false)
{
    global $cfg;
    if (empty($client_flags)) {
        if ($cfg['PersistentConnections'] || $persistant) {
            $link = @oci_pconnect($user, $password, $server, 'UTF8');
        } else {
            $link = @oci_connect($user, $password, $server, 'UTF8');
        }
    } else {
        if ($cfg['PersistentConnections'] || $persistant) {
            $link = @oci_pconnect($user, $password, $server, 'UTF8');
        } else {
            $link = @oci_connect($user, $password, $server, 'UTF8');
        }
    }
    return $link;
}
Example #28
0
 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     $foo =& $config['charset'];
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } elseif (empty($config['persistent'])) {
         $this->connection = @oci_new_connect($config['username'], $config['password'], $config['database'], $config['charset']);
         // intentionally @
     } else {
         $this->connection = @oci_pconnect($config['username'], $config['password'], $config['database'], $config['charset']);
         // intentionally @
     }
     if (!$this->connection) {
         $err = oci_error();
         throw new DibiDriverException($err['message'], $err['code']);
     }
 }
Example #29
0
 protected function connectInternal()
 {
     if ($this->isConnected) {
         return;
     }
     if (($this->dbOptions & self::PERSISTENT) != 0) {
         $connection = oci_pconnect($this->dbLogin, $this->dbPassword, $this->dbName);
     } else {
         $connection = oci_connect($this->dbLogin, $this->dbPassword, $this->dbName);
     }
     if (!$connection) {
         throw new ConnectionException('Oracle connect error', $this->getErrorMessage());
     }
     $this->isConnected = true;
     $this->resource = $connection;
     global $DB, $USER, $APPLICATION;
     if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) {
         include $fn;
     }
 }
Example #30
0
 /**
  * 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 = oci_pconnect($this->login, $this->password, $this->database);
     } else {
         $connection = oci_new_connect($this->login, $this->password, $this->database);
     }
     if (!$connection) {
         throw new ConnectionException('Oracle connect error', $this->getErrorMessage());
     }
     $this->isConnected = true;
     $this->resource = $connection;
     /** @noinspection PhpUnusedLocalVariableInspection */
     global $DB, $USER, $APPLICATION;
     if ($fn = \Bitrix\Main\Loader::getPersonal("php_interface/after_connect_d7.php")) {
         include $fn;
     }
 }