Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Zend\Db\Adapter - OCI8 Connection
Browse files Browse the repository at this point in the history
* Fixed up connect() method to allow looser connection options
* removed call_user_func() in favor of direct function calling
  • Loading branch information
ralphschindler committed Feb 6, 2013
1 parent 4df02fd commit 97477fe
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions library/Zend/Db/Adapter/Driver/Oci8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,12 @@ public function getResource()
/**
* Connect
*
* @return null
* @return Connection
*/
public function connect()
{
// @todo


if (is_resource($this->resource)) {
return;
return $this;
}

// localize
Expand All @@ -182,22 +179,24 @@ public function connect()
return null;
};

$hostname = $findParameterValue(array('hostname'));
// http://www.php.net/manual/en/function.oci-connect.php
$username = $findParameterValue(array('username'));
$password = $findParameterValue(array('password'));
$encoding = $findParameterValue(array('encoding'));
$connectionString = $findParameterValue(array('connection_string', 'connectionstring', 'connection', 'hostname', 'instance'));
$characterSet = $findParameterValue(array('character_set', 'charset', 'encoding'));

// connection modifiers
$isUnique = $findParameterValue(array('unique'));
$isPersistent = $findParameterValue(array('persistent'));

$connectionFuncName = 'oci_connect';
if ($isUnique === true) {
$connectionFuncName = 'oci_new_connect';
} elseif ($isPersistent === true) {
$connectionFuncName = 'oci_pconnect';
if ($isUnique == true) {
$this->resource = oci_new_connect($username, $password, $connectionString, $characterSet);
} elseif ($isPersistent == true) {
$this->resource = oci_pconnect($username, $password, $connectionString, $characterSet);
} else {
$this->resource = oci_connect($username, $password, $connectionString, $characterSet);
}

$this->resource = call_user_func($connectionFuncName, $username, $password, $hostname, $encoding);
if (!$this->resource) {
$e = oci_error();
throw new Exception\RuntimeException(
Expand Down

0 comments on commit 97477fe

Please sign in to comment.