本文整理汇总了PHP中OCIPLogon函数的典型用法代码示例。如果您正苦于以下问题:PHP OCIPLogon函数的具体用法?PHP OCIPLogon怎么用?PHP OCIPLogon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OCIPLogon函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dbi_connect
function dbi_connect($host, $login, $password, $database)
{
if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
$c = mysql_pconnect($host, $login, $password);
if ($c) {
if (!mysql_select_db($database)) {
return false;
}
return $c;
} else {
return false;
}
} else {
if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
if (strlen($host) && strcmp($host, "localhost")) {
$c = OCIPLogon("{$login}@{$host}", $password, $database);
} else {
$c = OCIPLogon($login, $password, $database);
}
$GLOBALS["oracle_connection"] = $c;
return $c;
} else {
if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
if (strlen($password)) {
$c = pg_connect("host={$host} dbname={$database} user={$login} password={$password}");
} else {
$c = pg_connect("host={$host} dbname={$database} user={$login}");
}
$GLOBALS["postgresql_connection"] = $c;
if (!$c) {
echo "Error connecting to database\n";
exit;
}
return $c;
} else {
if (strcmp($GLOBALS["db_type"], "odbc") == 0) {
if (strlen($host)) {
$c = odbc_pconnect("{$host}:{$database}", $login, $password);
} else {
$c = odbc_pconnect($database, $login, $password);
}
$GLOBALS["odbc_connection"] = $c;
return $c;
} else {
if (strcmp($GLOBALS["db_type"], "ibase") == 0) {
$c = ibase_connect($host, $login, $password);
return $c;
} else {
dbi_fatal_error("dbi_connect(): db_type not defined.");
}
}
}
}
}
}
示例2: sql_db
function sql_db($sqlserver, $sqluser, $sqlpassword, $database = "", $persistency = true)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->password = $sqlpassword;
$this->server = $sqlserver;
$this->dbname = $database;
if ($this->persistency) {
$this->db_connect_id = @OCIPLogon($this->user, $this->password, $this->server);
} else {
$this->db_connect_id = @OCINLogon($this->user, $this->password, $this->server);
}
if ($this->db_connect_id) {
return $this->db_connect_id;
} else {
return false;
}
}
示例3: _connect
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename,$mode=0)
{
if (!function_exists('OCIPLogon')) return null;
$this->_errorMsg = false;
$this->_errorCode = false;
if($argHostname) { // added by Jorma Tuomainen <jorma.tuomainen@ppoy.fi>
if (empty($argDatabasename)) $argDatabasename = $argHostname;
else {
if(strpos($argHostname,":")) {
$argHostinfo=explode(":",$argHostname);
$argHostname=$argHostinfo[0];
$argHostport=$argHostinfo[1];
} else {
$argHostport = empty($this->port)? "1521" : $this->port;
}
if ($this->connectSID) {
$argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
.")(PORT=$argHostport))(CONNECT_DATA=(SID=$argDatabasename)))";
} else
$argDatabasename="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=".$argHostname
.")(PORT=$argHostport))(CONNECT_DATA=(SERVICE_NAME=$argDatabasename)))";
}
}
//if ($argHostname) print "<p>Connect: 1st argument should be left blank for $this->databaseType</p>";
if ($mode==1) {
$this->_connectionID = ($this->charSet) ?
OCIPLogon($argUsername,$argPassword, $argDatabasename,$this->charSet)
:
OCIPLogon($argUsername,$argPassword, $argDatabasename)
;
if ($this->_connectionID && $this->autoRollback) OCIrollback($this->_connectionID);
} elseif ($mode==2) {
$this->_connectionID = ($this->charSet) ?
OCINLogon($argUsername,$argPassword, $argDatabasename,$this->charSet)
:
OCINLogon($argUsername,$argPassword, $argDatabasename);
} else {
$this->_connectionID = ($this->charSet) ?
OCILogon($argUsername,$argPassword, $argDatabasename,$this->charSet)
:
OCILogon($argUsername,$argPassword, $argDatabasename);
}
if (!$this->_connectionID) return false;
if ($this->_initdate) {
$this->Execute("ALTER SESSION SET NLS_DATE_FORMAT='".$this->NLS_DATE_FORMAT."'");
}
// looks like:
// Oracle8i Enterprise Edition Release 8.1.7.0.0 - Production With the Partitioning option JServer Release 8.1.7.0.0 - Production
// $vers = OCIServerVersion($this->_connectionID);
// if (strpos($vers,'8i') !== false) $this->ansiOuter = true;
return true;
}
示例4: dbi_connect
/**
* Opens up a database connection.
*
* Use a pooled connection if the db supports it and
* the <var>db_persistent</var> setting is enabled.
*
* <b>Notes:</b>
* - The database type is determined by the global variable
* <var>db_type</var>
* - For ODBC, <var>$host</var> is ignored, <var>$database</var> = DSN
* - For Oracle, <var>$database</var> = tnsnames name
* - Use the {@link dbi_error()} function to get error information if the connection
* fails
*
* @param string $host Hostname of database server
* @param string $login Database login
* @param string $password Database login password
* @param string $database Name of database
*
* @return resource The connection
*/
function dbi_connect($host, $login, $password, $database)
{
if (strcmp($GLOBALS["db_type"], "mysql") == 0) {
if ($GLOBALS["db_persistent"]) {
$c = mysql_pconnect($host, $login, $password);
} else {
$c = mysql_connect($host, $login, $password);
}
if ($c) {
if (!mysql_select_db($database)) {
return false;
}
return $c;
} else {
return false;
}
} else {
if (strcmp($GLOBALS["db_type"], "mysqli") == 0) {
if ($GLOBALS["db_persistent"]) {
$c = @mysqli_connect($host, $login, $password, $database);
} else {
$c = @mysqli_connect($host, $login, $password, $database);
}
if ($c) {
/*
if ( ! mysqli_select_db ( $c, $database ) )
return false;
*/
$GLOBALS["db_connection"] = $c;
return $c;
} else {
return false;
}
} else {
if (strcmp($GLOBALS["db_type"], "mssql") == 0) {
if ($GLOBALS["db_persistent"]) {
$c = mssql_pconnect($host, $login, $password);
} else {
$c = mssql_connect($host, $login, $password);
}
if ($c) {
if (!mssql_select_db($database)) {
return false;
}
return $c;
} else {
return false;
}
} else {
if (strcmp($GLOBALS["db_type"], "oracle") == 0) {
if (strlen($host) && strcmp($host, "localhost")) {
$c = OCIPLogon("{$login}@{$host}", $password, $database);
} else {
$c = OCIPLogon($login, $password, $database);
}
$GLOBALS["oracle_connection"] = $c;
return $c;
} else {
if (strcmp($GLOBALS["db_type"], "postgresql") == 0) {
if (strlen($password)) {
if (strlen($host)) {
$dbargs = "host={$host} dbname={$database} user={$login} password={$password}";
} else {
$dbargs = "dbname={$database} user={$login} password={$password}";
}
} else {
if (strlen($host)) {
$dbargs = "host={$host} dbname={$database} user={$login}";
} else {
$dbargs = "dbname={$database} user={$login}";
}
}
if ($GLOBALS["db_persistent"]) {
$c = pg_pconnect($dbargs);
} else {
$c = pg_connect($dbargs);
}
$GLOBALS["postgresql_connection"] = $c;
if (!$c) {
//.........这里部分代码省略.........