本文整理汇总了PHP中ociplogon函数的典型用法代码示例。如果您正苦于以下问题:PHP ociplogon函数的具体用法?PHP ociplogon怎么用?PHP ociplogon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ociplogon函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Connect
public function Connect()
{
// Lookup Adapter-Specific Connection Properties
$strServer = $this->Server;
$strName = $this->Database;
$strUsername = $this->Username;
$strPassword = $this->Password;
$strPort = $this->Port;
//echo "DB vars: ".$this->__get('Username');
// Connect to the Database Server
$this->objOracle = ociplogon($strUsername, $strPassword, "{$strServer}/{$strName}", 'UTF8');
if (!$this->objOracle) {
throw new QOracleDatabaseException("Unable to connect to Database", -1, null);
}
if ($objOracle_error = oci_error()) {
throw new QOracleDatabaseException($objOracle_error['message'], $objOracle_error['code'], null);
}
// Set to AutoCommit
//$this->NonQuery('SET AUTOCOMMIT=1;');
//Set SORT with special characteres
//$this->NonQuery("ALTER SESSION SET NLS_SORT=SPANISH");
// Update "Connected" Flag
$this->blnConnectedFlag = true;
$this->NonQuery("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD hh24:mi:ss'");
//$this->NonQuery("ALTER SESSION SET NLS_LANGUAGE='AMERICAN'");
// to use . instead of , for floating point
//$this->NonQuery("ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,'");
}
示例2: sql_connect
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . ($port ? ':' . $port : '');
$this->dbname = $database;
$this->db_connect_id = $this->persistency ? @ociplogon($this->user, $sqlpassword, $this->server) : @ocinlogon($this->user, $sqlpassword, $this->server);
return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
}
示例3: db_connect
function db_connect()
{
global $user,$pwd,$sid;
$conn=@ociplogon($user,$pwd,$sid);
if(!$conn)
trigger_error(db_error($conn),E_USER_ERROR);
$stmt=ociparse($conn,"alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'");
ociexecute($stmt);
ocifreestatement($stmt);
return $conn;
}
示例4: connect
/**
* Open a connection to db
*/
public function connect()
{
$this->conn = @ociplogon($this->user, $this->pwd, $this->sid);
if (!$this->conn) {
trigger_error($this->lastError(), E_USER_ERROR);
}
$stmt = ociparse($this->conn, "alter session set nls_date_format='YYYY-MM-DD HH24:MI:SS'");
ociexecute($stmt);
ocifreestatement($stmt);
return $this->conn;
}
示例5: da_sql_pconnect
function da_sql_pconnect($config)
{
if ($config[sql_use_http_credentials] == 'yes') {
global $HTTP_SERVER_VARS;
$SQL_user = $HTTP_SERVER_VARS["PHP_AUTH_USER"];
$SQL_passwd = $HTTP_SERVER_VARS["PHP_AUTH_PW"];
} else {
$SQL_user = $config[sql_username];
$SQL_passwd = $config[sql_password];
}
$link = @ociplogon($SQL_user, $SQL_passwd, $config[sql_database]);
$res = @da_sql_query($link, $config, "ALTER SESSION SET NLS_TIMESTAMP_TZ_FORMAT='YYYY-MM-DD HH24:MI:SS.FF TZH:TZM'");
return $link;
}
示例6: sql_connect
/**
* Connect to server
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . ($port ? ':' . $port : '');
$this->dbname = $database;
$connect = $database;
// support for "easy connect naming"
if ($sqlserver !== '' && $sqlserver !== '/') {
if (substr($sqlserver, -1, 1) == '/') {
$sqlserver == substr($sqlserver, 0, -1);
}
$connect = $sqlserver . ($port ? ':' . $port : '') . '/' . $database;
}
$this->db_connect_id = $new_link ? @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8') : ($this->persistency ? @ociplogon($this->user, $sqlpassword, $connect, 'UTF8') : @ocilogon($this->user, $sqlpassword, $connect, 'UTF8'));
return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
}
示例7: sql_connect
/**
* {@inheritDoc}
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . ($port ? ':' . $port : '');
$this->dbname = $database;
$connect = $database;
// support for "easy connect naming"
if ($sqlserver !== '' && $sqlserver !== '/') {
if (substr($sqlserver, -1, 1) == '/') {
$sqlserver == substr($sqlserver, 0, -1);
}
$connect = $sqlserver . ($port ? ':' . $port : '') . '/' . $database;
}
if ($new_link) {
if (!function_exists('ocinlogon')) {
$this->connect_error = 'ocinlogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ocinlogon($this->user, $sqlpassword, $connect, 'UTF8');
} else {
if ($this->persistency) {
if (!function_exists('ociplogon')) {
$this->connect_error = 'ociplogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ociplogon($this->user, $sqlpassword, $connect, 'UTF8');
} else {
if (!function_exists('ocilogon')) {
$this->connect_error = 'ocilogon function does not exist, is oci extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @ocilogon($this->user, $sqlpassword, $connect, 'UTF8');
}
}
return $this->db_connect_id ? $this->db_connect_id : $this->sql_error('');
}
示例8: ocidefinebyname
ocidefinebyname();
ocierror();
ociexecute();
ocifetch();
ocifetchinto();
ocifetchstatement();
ocifreecollection();
ocifreecursor();
ocifreedesc();
ocifreestatement();
ociinternaldebug();
ociloadlob();
ocilogoff();
ocilogon();
ocinewcollection();
ocinewcursor();
ocinewdescriptor();
ocinlogon();
ocinumcols();
ociparse();
ociplogon();
ociresult();
ocirollback();
ocirowcount();
ocisavelob();
ocisavelobfile();
ociserverversion();
ocisetprefetch();
ocistatementtype();
ociwritelobtofile();
ociwritetemporarylob();
示例9: db_pconnect
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
return @ociplogon($this->username, $this->password, $this->hostname);
}
示例10: DBconnect
function DBconnect(&$error)
{
$result = true;
global $DB;
$DB['DB'] = null;
$DB['TRANSACTIONS'] = 0;
//Stats
$DB['SELECT_COUNT'] = 0;
$DB['EXECUTE_COUNT'] = 0;
//SDI('type: '.$DB['TYPE'].'; server: '.$DB['SERVER'].'; port: '.$DB['PORT'].'; db: '.$DB['DATABASE'].'; usr: '.$DB['USER'].'; pass: '.$DB['PASSWORD']);
if (!isset($DB['TYPE'])) {
$error = "Unknown database type.";
$result = false;
} else {
switch ($DB['TYPE']) {
case 'MYSQL':
$mysql_server = $DB['SERVER'] . (!empty($DB['PORT']) ? ':' . $DB['PORT'] : '');
if (!($DB['DB'] = mysql_pconnect($mysql_server, $DB['USER'], $DB['PASSWORD']))) {
$error = 'Error connecting to database [' . mysql_error() . ']';
$result = false;
} else {
if (!mysql_select_db($DB['DATABASE'])) {
$error = 'Error database selection [' . mysql_error() . ']';
$result = false;
}
}
break;
case 'POSTGRESQL':
$pg_connection_string = (!empty($DB['SERVER']) ? 'host=\'' . $DB['SERVER'] . '\' ' : '') . 'dbname=\'' . $DB['DATABASE'] . '\' ' . (!empty($DB['USER']) ? 'user=\'' . $DB['USER'] . '\' ' : '') . (!empty($DB['PASSWORD']) ? 'password=\'' . $DB['PASSWORD'] . '\' ' : '') . (!empty($DB['PORT']) ? 'port=' . $DB['PORT'] : '');
$DB['DB'] = pg_connect($pg_connection_string);
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
}
break;
case 'ORACLE':
$DB['DB'] = ociplogon($DB['USER'], $DB['PASSWORD'], $DB['DATABASE']);
// $DB['DB']= ociplogon($DB['USER'], $DB['PASSWORD'], '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='.$DB['SERVER'].')(PORT=1521))(CONNECT_DATA=(SERVICE_NAME='.$DB['DATABASE'].')))');
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
}
break;
case 'SQLITE3':
$DB['TRANSACTIONS'] = 0;
if (!function_exists('init_db_access')) {
function init_db_access()
{
global $DB, $ZBX_SEM_ID;
$ZBX_SEM_ID = false;
if (function_exists('ftok') && function_exists('sem_get') && file_exists($DB['DATABASE'])) {
$ZBX_SEM_ID = sem_get(ftok($DB['DATABASE'], 'z'), 1);
}
}
}
if (!function_exists('lock_db_access')) {
function lock_db_access()
{
global $ZBX_SEM_ID;
if ($ZBX_SEM_ID && function_exists('sem_acquire')) {
sem_acquire($ZBX_SEM_ID);
}
}
}
if (!function_exists('unlock_db_access')) {
function unlock_db_access()
{
global $ZBX_SEM_ID;
if ($ZBX_SEM_ID && function_exists('sem_release')) {
sem_release($ZBX_SEM_ID);
}
}
}
if (!function_exists('free_db_access')) {
function free_db_access()
{
global $ZBX_SEM_ID;
if ($ZBX_SEM_ID && function_exists('sem_remove')) {
sem_remove($ZBX_SEM_ID);
}
$ZBX_SEM_ID = false;
}
}
if (file_exists($DB['DATABASE'])) {
$DB['DB'] = sqlite3_open($DB['DATABASE']);
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
}
} else {
$error = 'Missed database';
$result = false;
}
init_db_access();
break;
default:
$error = 'Unsupported database';
$result = false;
}
}
//.........这里部分代码省略.........
示例11: pConnect
/**
* Makes a persistent database connection.
* Makes a persistent database connection.
* @access public
* @return mixed The connection's link identifier, if successful; False, otherwise.
*/
function pConnect()
{
// if connected, need to disconnect first
if ($this->isConnected()) {
return false;
}
$linkId = ociplogon($this->_dbUser, $this->_dbPass, $this->_dbName);
// see if successful
if ($linkId) {
// reset the query counters
$this->_successfulQueries = 0;
$this->_failedQueries = 0;
$this->_linkId = $linkId;
return $linkId;
} else {
throw new ConnectionDatabaseException($this->getConnectionErrorInfo() . "Cannot connect to database.");
$this->_linkId = false;
return false;
}
}
示例12: connect
/**
* Connects to the database using options in the given configuration array.
*
* @return boolean True if the database could be connected, else false
* @access public
*/
function connect()
{
$config = $this->config;
$this->connected = false;
$config['charset'] = !empty($config['charset']) ? $config['charset'] : null;
if (!$config['persistent']) {
$this->connection = @ocilogon($config['login'], $config['password'], $config['database'], $config['charset']);
} else {
$this->connection = @ociplogon($config['login'], $config['password'], $config['database'], $config['charset']);
}
if ($this->connection) {
$this->connected = true;
if (!empty($config['nls_sort'])) {
$this->execute('ALTER SESSION SET NLS_SORT=' . $config['nls_sort']);
}
if (!empty($config['nls_comp'])) {
$this->execute('ALTER SESSION SET NLS_COMP=' . $config['nls_comp']);
}
$this->execute("ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'");
} else {
$this->connected = false;
$this->_setError();
return false;
}
return $this->connected;
}
示例13: DBconnect
function DBconnect(&$error)
{
$result = true;
global $DB;
$DB['DB'] = null;
$DB['TRANSACTIONS'] = 0;
//Stats
$DB['SELECT_COUNT'] = 0;
$DB['EXECUTE_COUNT'] = 0;
//SDI('type: '.$DB['TYPE'].'; server: '.$DB['SERVER'].'; port: '.$DB['PORT'].'; db: '.$DB['DATABASE'].'; usr: '.$DB['USER'].'; pass: '.$DB['PASSWORD']);
if (!isset($DB['TYPE'])) {
$error = "Unknown database type.";
$result = false;
} else {
$DB['TYPE'] = zbx_strtoupper($DB['TYPE']);
switch ($DB['TYPE']) {
case 'MYSQL':
$mysql_server = $DB['SERVER'] . (!empty($DB['PORT']) ? ':' . $DB['PORT'] : '');
if (!($DB['DB'] = mysql_connect($mysql_server, $DB['USER'], $DB['PASSWORD']))) {
$error = 'Error connecting to database [' . mysql_error() . ']';
$result = false;
} else {
if (!mysql_select_db($DB['DATABASE'])) {
$error = 'Error database in selection [' . mysql_error() . ']';
$result = false;
} else {
DBexecute('SET NAMES utf8');
DBexecute('SET CHARACTER SET utf8');
}
}
break;
case 'POSTGRESQL':
$pg_connection_string = (!empty($DB['SERVER']) ? 'host=\'' . $DB['SERVER'] . '\' ' : '') . 'dbname=\'' . $DB['DATABASE'] . '\' ' . (!empty($DB['USER']) ? 'user=\'' . $DB['USER'] . '\' ' : '') . (!empty($DB['PASSWORD']) ? 'password=\'' . $DB['PASSWORD'] . '\' ' : '') . (!empty($DB['PORT']) ? 'port=' . $DB['PORT'] : '');
$DB['DB'] = pg_connect($pg_connection_string);
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
}
break;
case 'ORACLE':
$connect = '';
if (!empty($DB['SERVER'])) {
$connect = '//' . $DB['SERVER'];
if ($DB['PORT'] != '0') {
$connect .= ':' . $DB['PORT'];
}
if ($DB['DATABASE']) {
$connect .= '/' . $DB['DATABASE'];
}
}
$DB['DB'] = ociplogon($DB['USER'], $DB['PASSWORD'], $connect);
// $DB['DB']= ociplogon($DB['USER'], $DB['PASSWORD'], '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='.$DB['SERVER'].')(PORT=1521))(CONNECT_DATA=(SERVICE_NAME='.$DB['DATABASE'].')))');
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
}
break;
case 'IBM_DB2':
$connect = '';
$connect .= 'DATABASE=' . $DB['DATABASE'] . ';';
$connect .= 'HOSTNAME=' . $DB['SERVER'] . ';';
$connect .= 'PORT=' . $DB['PORT'] . ';';
$connect .= 'PROTOCOL=TCPIP;';
$connect .= 'UID=' . $DB['USER'] . ';';
$connect .= 'PWD=' . $DB['PASSWORD'] . ';';
$DB['DB'] = db2_connect($connect, $DB['USER'], $DB['PASSWORD']);
if (!$DB['DB']) {
$error = 'Error connecting to database';
$result = false;
} else {
$options = array('db2_attr_case' => DB2_CASE_LOWER);
db2_set_option($DB['DB'], $options, 1);
if (isset($DB['SCHEMA']) && $DB['SCHEMA'] != '') {
DBexecute("SET CURRENT SCHEMA='" . $DB['SCHEMA'] . "'");
}
}
break;
case 'SQLITE3':
$DB['TRANSACTIONS'] = 0;
if (!function_exists('init_db_access')) {
function init_db_access()
{
global $DB, $ZBX_SEM_ID;
$ZBX_SEM_ID = false;
if (function_exists('ftok') && function_exists('sem_get') && file_exists($DB['DATABASE'])) {
$ZBX_SEM_ID = sem_get(ftok($DB['DATABASE'], 'z'), 1);
}
}
}
if (!function_exists('lock_db_access')) {
function lock_db_access()
{
global $ZBX_SEM_ID;
if ($ZBX_SEM_ID && function_exists('sem_acquire')) {
sem_acquire($ZBX_SEM_ID);
}
}
}
if (!function_exists('unlock_db_access')) {
function unlock_db_access()
//.........这里部分代码省略.........
示例14: db_get_connection
/**
* Get a database connection. This function shouldn't be used by you, as a connection to the database is established automatically.
*
* @param boolean Whether to create a persistant connection
* @param string The database name
* @param string The database host (the server)
* @param string The database connection username
* @param string The database connection password
* @param boolean Whether to on error echo an error and return with a NULL, rather than giving a critical error
* @return ?array A database connection (NULL: failed)
*/
function db_get_connection($persistent, $db_name, $db_host, $db_user, $db_password, $fail_ok = false)
{
if ($db_host != 'localhost') {
fatal_exit(do_lang_tempcode('ONLY_LOCAL_HOST_FOR_TYPE'));
}
// Potential cacheing
global $CACHE_DB;
if (isset($CACHE_DB[$db_name][$db_host])) {
return $CACHE_DB[$db_name][$db_host];
}
if (!function_exists('ocilogon')) {
$error = 'The oracle PHP extension not installed (anymore?). You need to contact the system administrator of this server.';
if ($fail_ok) {
echo $error;
return NULL;
}
critical_error('PASSON', $error);
}
$db = $persistent ? @ociplogon($db_user, $db_password, $db_name) : @ocilogon($db_user, $db_password, $db_name);
if ($db === false) {
$error = 'Could not connect to database-server (' . ocierror() . ')';
if ($fail_ok) {
echo $error;
return NULL;
}
critical_error('PASSON', $error);
//warn_exit(do_lang_tempcode('CONNECT_DB_ERROR'));
}
if (!$db) {
fatal_exit(do_lang('CONNECT_DB_ERROR'));
}
$CACHE_DB[$db_name][$db_host] = $db;
return $db;
}
示例15: db_pconnect
/**
* Persistent database connection
*
* @access private called by the base class
* @return resource
*/
function db_pconnect()
{
// ====== Modificación por CRIE - UTP =======
// Se agrega el parámetro utf8 a la función ocilogon para
// forzar el uso de la codificación UTF-8 en Oracle
return @ociplogon($this->username, $this->password, $this->hostname, 'utf8');
// ========= Fin Modificación =========
}