Closed ekarlso closed 12 years ago
I'll just paste it here instead since I can't push to git at the moment.
<?php defined('SYSPATH') or die('No direct access allowed.');
$config = array();
$config['default'] = array( 'type' => 'mysql', // string (e.g. db2, drizzle, firebird, mariadb, mssql, mysql, oracle, postgresql, or sqlite) 'driver' => 'standard', // string (e.g. standard, improved, or pdo) 'connection' => array( 'persistent' => FALSE, // boolean 'hostname' => '', // string 'port' => '', // string 'database' => '', // string 'username' => 'root', // string 'password' => 'root', // string ), 'caching' => FALSE, // boolean 'charset' => 'utf8', // string 'profiling' => FALSE, // boolean 'table_prefix' => '', // string );
return $config; ?>
public function open() {
if ( ! $this->is_connected()) {
$host = $this->data_source->host;
$database = $this->data_source->database;
if ( ! empty($host) ) {
$connection_string = '//'. $this->data_source->host;
$port = $this->data_source->port; // default port is 1521
if ( ! empty($port)) {
$connection_string .= ':' . $port;
}
$connection_string .= '/' . $this->data_source->database;
} elseif ( isset($database) ) {
$connection_string = $this->data_source->database;
} else {
throw new Kohana_Database_Exception("Bad configuration, need either a //host[:port][/service_name] or a database name scheme");
}
$username = $this->data_source->username;
$password = $this->data_source->password;
#echo $connection_string . "<br/>";
$this->link_id = ($this->data_source->is_persistent())
? @oci_pconnect($username, $password, $connection_string)
: @oci_connect($username, $password, $connection_string);
if ($this->link_id === FALSE) {
$oci_error = oci_error();
$this->error = 'Message: Failed to establish connection. Reason: ' . $oci_error['message'];
throw new Kohana_Database_Exception($this->error, array(':dsn' => $this->data_source->id));
}
$this->execution_mode = OCI_COMMIT_ON_SUCCESS;
}
}
Awesome! I will integrate this code in today and make the necessary changes elsewhere in the code to allow for this.
In Oracle you can use just the SID / Service Name to connect to the database (it will look up the db via LDAP or tnsnames.ora)
See the attached file.