• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP oci_new_connect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: connect

 /**
  * 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'];
     } else {
         $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:jaroslavlibal,项目名称:MDW,代码行数:21,代码来源:oracle.php


示例17: connectInternal

 /**
  * 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();
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:25,代码来源:oracleconnection.php


示例18: open

 /**
  * Usually aborts on failure
  * If the failFunction is set to a non-zero integer, returns success
  */
 function open($server, $user, $password, $dbName)
 {
     if (!function_exists('oci_connect')) {
         throw new DBConnectionError($this, "Oracle functions missing, have you compiled PHP with the --with-oci8 option?\n");
     }
     $this->close();
     $this->mServer = $server;
     $this->mUser = $user;
     $this->mPassword = $password;
     $this->mDBname = $dbName;
     $this->mConn = oci_new_connect($user, $password, $dbName, "AL32UTF8");
     if ($this->mConn === false) {
         wfDebug("DB connection error\n");
         wfDebug("Server: {$server}, Database: {$dbName}, User: {$user}, Password: " . substr($password, 0, 3) . "...\n");
         wfDebug($this->lastError() . "\n");
     } else {
         $this->mOpened = true;
     }
     return $this->mConn;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:24,代码来源:DatabaseOracle.php


示例19: connectInternal

 /**
  * 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;
     }
 }
开发者ID:Satariall,项目名称:izurit,代码行数:29,代码来源:oracleconnection.php


示例20: initConnection

 /**
  * Inits connection
  */
 protected function initConnection($username = null, $passwd = null)
 {
     if (is_null(self::$_parsedDsn['charset'])) {
         self::$_parsedDsn['charset'] = 'UTF8';
     }
     $session_mode = OCI_DEFAULT;
     if ($username === '/' && empty($passwd)) {
         $session_mode = OCI_CRED_EXT;
     }
     if ($this->getAttribute(PDO::ATTR_PERSISTENT)) {
         $this->_dbh = @oci_pconnect($username, $passwd, self::$_parsedDsn['dbname'], self::$_parsedDsn['charset'], $session_mode);
     } else {
         $this->_dbh = @oci_new_connect($username, $passwd, self::$_parsedDsn['dbname'], self::$_parsedDsn['charset'], $session_mode);
     }
     if (YII_DEBUG) {
         $this->checkError($this->_dbh);
     } else {
         if ($this->_dbh === false) {
             throw new CDbNoConnectionException('No DB');
         }
     }
 }
开发者ID:neutrinobg,项目名称:yii2-oci2pdo,代码行数:25,代码来源:OciPdoAdapter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP oci_new_cursor函数代码示例发布时间:2022-05-15
下一篇:
PHP oci_free_statement函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap