Skip to content

Commit

Permalink
Merge branch 'hamilok-oracle_fix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphschindler committed Feb 6, 2013
2 parents 5a632e4 + 97477fe commit 25764a3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
35 changes: 21 additions & 14 deletions library/Zend/Db/Adapter/Driver/Oci8/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public function getCurrentSchema()
$this->connect();
}

$query = "SELECT sys_context('USERENV', 'DB_NAME') as \"database_name\" FROM DUAL";
$query = "SELECT sys_context('USERENV', 'CURRENT_SCHEMA') as \"current_schema\" FROM DUAL";
$stmt = oci_parse($this->resource, $query);
oci_execute($stmt);
$dbNameArray = oci_fetch_array($stmt, OCI_ASSOC);
return $dbNameArray['database_name'];
return $dbNameArray['current_schema'];
}

/**
Expand Down 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,15 +179,24 @@ public function connect()
return null;
};

// $hostname = $findParameterValue(array('hostname', 'host_name', ';host'));
$username = $findParameterValue(array('username', 'user'));
// http://www.php.net/manual/en/function.oci-connect.php
$username = $findParameterValue(array('username'));
$password = $findParameterValue(array('password'));
$connectString = $findParameterValue(array('connection_string', 'connectionstring', 'connection', 'instance'));
//$service = $findParameterValue(array('service_name', 'service', 'db', 'schema'));
//$port = (isset($p['port'])) ? (int) $p['port'] : null;
//$socket = (isset($p['socket'])) ? $p['socket'] : null;
$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'));

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 = oci_connect($username, $password, $connectString);
if (!$this->resource) {
$e = oci_error();
throw new Exception\RuntimeException(
Expand All @@ -199,6 +205,7 @@ public function connect()
new Exception\ErrorException($e['message'], $e['code'])
);
}

return $this;
}

Expand Down
3 changes: 3 additions & 0 deletions library/Zend/Db/Adapter/Driver/Oci8/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ protected function bindParametersFromContainer()
$value = (int) $value;
}
break;
case ParameterContainer::TYPE_BINARY:
$type = SQLT_BIN;
break;
case ParameterContainer::TYPE_STRING:
default:
$type = SQLT_CHR;
Expand Down
1 change: 1 addition & 0 deletions library/Zend/Db/Adapter/ParameterContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class ParameterContainer implements \Iterator, \ArrayAccess, \Countable
const TYPE_NULL = 'null';
const TYPE_DOUBLE = 'double';
const TYPE_INTEGER = 'integer';
const TYPE_BINARY = 'binary';
const TYPE_STRING = 'string';
const TYPE_LOB = 'lob';

Expand Down

0 comments on commit 25764a3

Please sign in to comment.