当前位置: 首页>>代码示例>>PHP>>正文


PHP oci_new_connect函数代码示例

本文整理汇总了PHP中oci_new_connect函数的典型用法代码示例。如果您正苦于以下问题:PHP oci_new_connect函数的具体用法?PHP oci_new_connect怎么用?PHP oci_new_connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了oci_new_connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isset

 protected function &connect($new = false, $suppress = false)
 {
     $this->setConnectionString();
     isset($this->connectionSettings['session_mode']) ?: ($this->connectionSettings['session_mode'] = null);
     if ($new) {
         $resource = oci_new_connect($this->connectionSettings['username'], $this->connectionSettings['password'], $this->connectionString, $this->connectionSettings['charset'], $this->connectionSettings['session_mode']);
         if (!$resource) {
             $t = count($this->errorStack);
             $this->errorStack[$t]['error'] = oci_error($this->resource);
             $this->errorStack[$t]['trace'] = debug_backtrace(0, 3);
             Error::getMessage(null, $this->errorStack[$t]['trace'], $this->errorStack[$t]['error'], $suppress);
         }
         return $resource;
     } else {
         $this->resource = oci_connect($this->connectionSettings['username'], $this->connectionSettings['password'], $this->connectionString, $this->connectionSettings['charset'], $this->connectionSettings['session_mode']);
         if (!$this->resource) {
             $t = count($this->errorStack);
             $this->errorStack[$t]['error'] = oci_error($this->resource);
             $this->errorStack[$t]['trace'] = debug_backtrace(0, 3);
             Error::getMessage(null, $this->errorStack[$t]['trace'], $this->errorStack[$t]['error'], $suppress);
         }
         return $this->resource;
     }
 }
开发者ID:khooz,项目名称:oci-classes,代码行数:24,代码来源:Connection.php

示例2: connect

 /**
  * {@inheritdoc}
  *
  * @throws \Orno\Db\Exception\ConnectionException
  * @param  array $config
  * @return \Orno\Db\Driver\Oci8
  */
 public function connect(array $config = [])
 {
     if (is_resource($this->connection)) {
         return $this;
     }
     // filter config array
     $persistent = isset($config['persistent']) ? (bool) $config['persistent'] : true;
     $database = isset($config['database']) ? $config['database'] : $this->config['database'];
     $username = isset($config['username']) ? $config['username'] : $this->config['username'];
     $password = isset($config['password']) ? $config['password'] : $this->config['password'];
     $charset = isset($config['charset']) ? $config['charset'] : 'AL32UTF8';
     // intentionally supress errors to catch with oci_error
     $this->connection = $persistent === true ? @oci_pconnect($username, $password, $database, $charset) : @oci_new_connect($username, $password, $database, $charset);
     if (!$this->connection) {
         $e = oci_error();
         throw new Exception\ConnectionException($e['message'], $e['code']);
     }
     return $this;
 }
开发者ID:orno,项目名称:db,代码行数:26,代码来源:Oci8.php

示例3: connect

 protected function connect(&$username, &$password, &$driver_options)
 {
     $dbname = isset($this->dsn['dbname']) ? $this->dsn['dbname'] : '';
     $charset = isset($this->dsn['charset']) ? $this->dsn['charset'] : (isset($_ENV['NLS_LANG']) ? $_ENV['NLS_LANG'] : 'WE8ISO8859P1');
     ob_start();
     if (isset($driver_options[PDO::ATTR_PERSISTENT]) && $driver_options[PDO::ATTR_PERSISTENT]) {
         $this->link = oci_pconnect($username, $password, $dbname, $charset);
     } else {
         $this->link = oci_new_connect($username, $password, $dbname, $charset);
     }
     $error = ob_get_contents();
     ob_end_clean();
     if (!$this->link) {
         $this->set_driver_error(null, PDO::ERRMODE_EXCEPTION, '__construct');
     } else {
         if ($error) {
             $this->set_error(0, $this->clear_warning($error), 'HY000', PDO::ERRMODE_EXCEPTION, '__construct');
         }
     }
 }
开发者ID:Deepab23,项目名称:clinic,代码行数:20,代码来源:oci.php

示例4: connect

 /**
  * Connect to db
  * Must be called before other methods.
  * @param string $dbhost The database host.
  * @param string $dbuser The database username.
  * @param string $dbpass The database username's password.
  * @param string $dbname The name of the database being connected to.
  * @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
  * @param array $dboptions driver specific options
  * @return bool true
  * @throws dml_connection_exception if error
  */
 public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions = null)
 {
     if ($prefix == '' and !$this->external) {
         //Enforce prefixes for everybody but mysql
         throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
     }
     if (!$this->external and strlen($prefix) > 2) {
         //Max prefix length for Oracle is 2cc
         $a = (object) array('dbfamily' => 'oracle', 'maxlength' => 2);
         throw new dml_exception('prefixtoolong', $a);
     }
     $driverstatus = $this->driver_installed();
     if ($driverstatus !== true) {
         throw new dml_exception('dbdriverproblem', $driverstatus);
     }
     // Autocommit ON by default.
     // Switching to OFF (OCI_DEFAULT), when playing with transactions
     // please note this thing is not defined if oracle driver not present in PHP
     // which means it can not be used as default value of object property!
     $this->commit_status = OCI_COMMIT_ON_SUCCESS;
     $this->store_settings($dbhost, $dbuser, $dbpass, $dbname, $prefix, $dboptions);
     unset($this->dboptions['dbsocket']);
     // NOTE: use of ', ", / and \ is very problematic, even native oracle tools seem to have
     //       problems with these, so just forget them and do not report problems into tracker...
     if (empty($this->dbhost)) {
         // old style full address (TNS)
         $dbstring = $this->dbname;
     } else {
         if (empty($this->dboptions['dbport'])) {
             $this->dboptions['dbport'] = 1521;
         }
         $dbstring = '//' . $this->dbhost . ':' . $this->dboptions['dbport'] . '/' . $this->dbname;
     }
     ob_start();
     if (empty($this->dboptions['dbpersist'])) {
         $this->oci = oci_new_connect($this->dbuser, $this->dbpass, $dbstring, 'AL32UTF8');
     } else {
         $this->oci = oci_pconnect($this->dbuser, $this->dbpass, $dbstring, 'AL32UTF8');
     }
     $dberr = ob_get_contents();
     ob_end_clean();
     if ($this->oci === false) {
         $this->oci = null;
         $e = oci_error();
         if (isset($e['message'])) {
             $dberr = $e['message'];
         }
         throw new dml_connection_exception($dberr);
     }
     // get unique session id, to be used later for temp tables stuff
     $sql = 'SELECT DBMS_SESSION.UNIQUE_SESSION_ID() FROM DUAL';
     $this->query_start($sql, null, SQL_QUERY_AUX);
     $stmt = $this->parse_query($sql);
     $result = oci_execute($stmt, $this->commit_status);
     $this->query_end($result, $stmt);
     $records = null;
     oci_fetch_all($stmt, $records, 0, -1, OCI_FETCHSTATEMENT_BY_ROW);
     oci_free_statement($stmt);
     $this->unique_session_id = reset($records[0]);
     //note: do not send "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,'" !
     //      instead fix our PHP code to convert "," to "." properly!
     // Connection stabilised and configured, going to instantiate the temptables controller
     $this->temptables = new oci_native_moodle_temptables($this, $this->unique_session_id);
     return true;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:77,代码来源:oci_native_moodle_database.php

示例5: __construct

 /**
  * Doctrine Oracle adapter constructor
  *
  * <code>
  * $conn = new Doctrine_Adapter_Oracle(array('dbname'=>'db','username'=>'usr','password'=>'pass'));
  * </code>
  *
  * or
  *
  * <code>
  * Doctrine_Manager::connection(array('oracle:dbname=SID;charset=NLS_CHARACTERSET;persistent=true','usr', 'pass'),"doctrine_connection_name")
  * </code>
  *
  * @param string $name
  * @return void
  */
 public function __construct($config = array(), $username = null, $password = null)
 {
     if (is_string($config)) {
         $config = str_replace("oracle:", "", $config);
         $parts = explode(";", $config);
         foreach ($parts as $part) {
             $e = explode("=", $part);
             $key = array_shift($e);
             $this->config[$key] = implode('=', $e);
         }
         if ($username) {
             $this->config['username'] = $username;
         }
         if ($password) {
             $this->config['password'] = $password;
         }
     } else {
         if (!isset($config['password']) || !isset($config['username'])) {
             throw new Doctrine_Adapter_Exception('config array must have at least a username and a password');
         }
         $this->config['username'] = $config['username'];
         $this->config['password'] = $config['password'];
         $this->config['dbname'] = $config['dbname'];
         if (isset($config['charset'])) {
             $this->config['charset'] = $config['charset'];
         }
         if (isset($config['persistent'])) {
             $this->config['persistent'] = $config['persistent'];
         }
     }
     if ($this->config['persistent'] == 'true') {
         $this->connection = @oci_pconnect($this->config['username'], $this->config['password'], $this->config['dbname'], $this->config['charset']);
     } else {
         $this->connection = @oci_new_connect($this->config['username'], $this->config['password'], $this->config['dbname'], $this->config['charset']);
     }
     if ($this->connection === false) {
         throw new Doctrine_Adapter_Exception(sprintf("Unable to Connect to :'%s' as '%s'", $this->config['dbname'], $this->config['username']));
     }
 }
开发者ID:tests1,项目名称:zendcasts,代码行数:55,代码来源:Oracle.php

示例6: connect

 /**
  * Connect to the Oracle server using a unique connection
  *
  * @param string $username
  * @param string $password
  * @param string $connectionString
  * @param string $characterSet
  * @param int $sessionMode
  * @return resource
  * @throws \Jpina\Oci8\Oci8Exception
  * @see http://php.net/manual/en/function.oci-new-connect.php
  */
 protected function connect($username, $password, $connectionString = null, $characterSet = null, $sessionMode = null)
 {
     set_error_handler(static::getErrorHandler());
     $connection = oci_new_connect($username, $password, $connectionString, $characterSet, $sessionMode);
     restore_error_handler();
     return $connection;
 }
开发者ID:jpina,项目名称:oci8,代码行数:19,代码来源:Oci8Connection.php

示例7: __construct

 /**
 	Initialise an oracle database.
 
 	This database driver accepts the following parameters:
 	 * user:		The user used to connect to the database.
 	 * password:	The password of the user.
 	 * dbname:		The name of the database.
 	 * encoding:	The encoding used for the connection (defaults to UTF8).
 
 	@param	$aParams	The arguments of the connection.
 */
 public function __construct($aParams = array())
 {
     function_exists('oci_new_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'OCI8'));
     // oci_new_connect triggers a warning when the connection failed.
     $this->rLink = @oci_new_connect(array_value($aParams, 'user'), array_value($aParams, 'password'), array_value($aParams, 'dbname'), array_value($aParams, 'encoding', 'UTF8'));
     $this->rLink !== false or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), array_value(oci_error(), 'message')));
 }
开发者ID:extend,项目名称:wee,代码行数:18,代码来源:weeOracleDatabase.class.php

示例8: connect

 public function connect()
 {
     $this->conn = oci_new_connect($this->username, $this->password, $this->db_conn_string);
     if (!$this->conn) {
         $e = oci_error();
         trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
     }
 }
开发者ID:ismailmare,项目名称:Photoshare,代码行数:8,代码来源:db.php

示例9: connect

 /**
  * Connect to MySQL, but not to a database
  *
  * @param string $dbuser Username
  * @param string $dbpassword Password
  * @return bool Success
  *
  */
 public function connect($dbuser = '', $dbpassword = '', $dbname = '')
 {
     if (!($this->dbh = oci_new_connect($dbuser, $dbpassword, $dbname))) {
         $err = ocierror();
         $this->register_error($err['message'], $err['code']);
         return false;
     } else {
         $this->clear_errors();
         return true;
     }
 }
开发者ID:jaywilliams,项目名称:ultralite,代码行数:19,代码来源:Oracle.php

示例10: __construct

 /**
  * 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
  * @throws \Exception
  */
 public function __construct($module, $cid)
 {
     $this->conn = @oci_new_connect(O_USERNAME, O_PASSWORD, O_DATABASE, O_CHARSET);
     if (!$this->conn) {
         $m = oci_error();
         throw new \Exception("Cannot open connection to Oracle db " . $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);
 }
开发者ID:kwakucsc,项目名称:php_framework,代码行数:19,代码来源:Oracle.php

示例11: connect

 /**
  * Connects to a database.
  *
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     DibiConnection::alias($config, 'database', 'db');
     DibiConnection::alias($config, 'charset');
     $this->connection = @oci_new_connect($config['username'], $config['password'], $config['database'], $config['charset']);
     // intentionally @
     if (!$this->connection) {
         $err = oci_error();
         throw new DibiDriverException($err['message'], $err['code']);
     }
 }
开发者ID:laiello,项目名称:webuntucms,代码行数:19,代码来源:oracle.php

示例12: getInstance

 public static function getInstance()
 {
     if (!isset(self::$conn)) {
         // var_dump(SERVER); exit();
         self::$conn = oci_new_connect(USER, PASS, SERVER . "/" . SID, CHARTSET);
         if (!self::$conn) {
             $m = oci_error();
             echo $m['message'], "n";
             exit;
         }
     }
     return self::$conn;
 }
开发者ID:vanckruz,项目名称:draftReports,代码行数:13,代码来源:orcl_conex.php

示例13: Connect

 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;
 }
开发者ID:Zniel,项目名称:fl_crtlpanel_self_dev,代码行数:14,代码来源:pm_oracle.class.php

示例14: connect

 public function connect(array $params)
 {
     $database = "//" . $params["host"] . "/" . $params["database"];
     $encoding = isset($params["charset"]) ? $params["charset"] : null;
     $conn = oci_new_connect($params["user"], $params["password"], $database, $encoding);
     if ($conn) {
         $stmt = oci_parse($conn, "ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
         oci_execute($stmt, OCI_COMMIT_ON_SUCCESS);
         return $conn;
     } else {
         $e = oci_error();
         return $e["message"];
     }
 }
开发者ID:reoring,项目名称:sabel,代码行数:14,代码来源:Driver.php

示例15: connect

 /** connect establishes the link
  * @return the class
  */
 public function connect()
 {
     try {
         if (!($this->link = @oci_new_connect(DATABASE_USERNAME, DATABASE_PASSWORD, '//' . DATABASE_HOST . '/' . DATABASE_NAME))) {
             throw new Exception(sprintf('Host: %s, Username: %s, Database: %s, Error: %s', DATABASE_HOST, DATABASE_USERNAME, DATABASE_NAME, @oci_error()));
         }
         if (!$this->link->select_db(DATABASE_NAME)) {
             throw new Exception(_('Issue working with the current DB, maybe it has not been created yet'));
         }
     } catch (Exception $e) {
         $this->debug(sprintf('Failed to %s: %s', __FUNCTION__, $e->getMessage()));
     }
     return $this;
 }
开发者ID:bramverstraten,项目名称:fogproject,代码行数:17,代码来源:Oracle.class.php


注:本文中的oci_new_connect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。