Doctrine 1.2.4
Doctrine_Adapter_Oracle Class Reference

Inherits Doctrine_Adapter_Interface.

Public Member Functions

 __construct ($config=array(), $username=null, $password=null)
 
 beginTransaction ()
 
 commit ()
 
 exec ($statement)
 
 getAttribute ($attribute)
 
 getConnection ()
 
 getUserName ()
 
 lastInsertId ()
 
 prepare ($query)
 
 query ($query)
 
 quote ($input)
 
 rollBack ()
 
 setAttribute ($attribute, $value)
 

Protected Attributes

 $connection = false
 
 $executeMode = OCI_COMMIT_ON_SUCCESS
 

Detailed Description

Definition at line 36 of file Oracle.php.

Constructor & Destructor Documentation

Doctrine_Adapter_Oracle::__construct (   $config = array(),
  $username = null,
  $password = null 
)

Doctrine Oracle adapter constructor

$conn = new Doctrine_Adapter_Oracle(array('dbname'=>'db','username'=>'usr','password'=>'pass'));

or

Doctrine_Manager::connection(array('oracle:dbname=SID;charset=NLS_CHARACTERSET;persistent=true','usr', 'pass'),"doctrine_connection_name")

Parameters
string$name
Returns
void

Definition at line 88 of file Oracle.php.

{
if (is_string($config))
{
$config = str_replace("oracle:","",$config);
$parts = explode(";", $config);
foreach($parts as $part) {
$e = explode("=", $part);
$key = array_shift($e);
$this->config[$key] = implode('=', $e);
}
if ($username) {
$this->config['username'] = $username;
}
if ($password) {
$this->config['password'] = $password;
}
} else {
if ( ! isset($config['password']) || ! isset($config['username'])) {
throw new Doctrine_Adapter_Exception('config array must have at least a username and a password');
}
$this->config['username'] = $config['username'];
$this->config['password'] = $config['password'];
$this->config['dbname'] = $config['dbname'];
if (isset($config['charset'])) {
$this->config['charset'] = $config['charset'];
}
if (isset($config['persistent'])) {
$this->config['persistent'] = $config['persistent'];
}
}
if ($this->config['persistent'] == 'true'){
$this->connection = @oci_pconnect($this->config['username'], $this->config['password'],
$this->config['dbname'], $this->config['charset']);
} else {
$this->connection = @oci_new_connect($this->config['username'], $this->config['password'],
$this->config['dbname'], $this->config['charset']);
}
if ($this->connection === false) {
throw new Doctrine_Adapter_Exception(sprintf("Unable to Connect to :'%s' as '%s'", $this->config['dbname'], $this->config['username']));
}
}

Member Function Documentation

Doctrine_Adapter_Oracle::beginTransaction ( )

Begin a transaction

Returns
boolean

Definition at line 206 of file Oracle.php.

{
$this->executeMode = OCI_DEFAULT;
return true;
}
Doctrine_Adapter_Oracle::commit ( )

Commit a transaction

Returns
void

Definition at line 217 of file Oracle.php.

{
return @oci_commit($this->connection);
}
Doctrine_Adapter_Oracle::exec (   $statement)

Execute a raw sql statement

Parameters
string$statement
Returns
void

Definition at line 182 of file Oracle.php.

{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $statement, $this->executeMode);
$stmt->execute();
$count = $stmt->rowCount();
return $count;
}
Doctrine_Adapter_Oracle::getAttribute (   $attribute)

Retrieve a statement attribute

Parameters
integer$attribute
See Also
Doctrine_Core::ATTR_* constants
Returns
mixed the attribute value

Definition at line 267 of file Oracle.php.

{
return $this->attributes[$attribute];
}
Doctrine_Adapter_Oracle::getConnection ( )

Returns established OCI connection handler

Returns
resource OCI connection handler

Definition at line 277 of file Oracle.php.

{
}
Doctrine_Adapter_Oracle::getUserName ( )

Returns current user name

Returns
string current user name

Definition at line 287 of file Oracle.php.

{
return $this->config['username'];
}
Doctrine_Adapter_Oracle::lastInsertId ( )

Get the id of the last inserted record

Returns
integer $id

Definition at line 196 of file Oracle.php.

{
throw new Doctrine_Adapter_Exception("unsupported");
}
Doctrine_Adapter_Oracle::prepare (   $query)

Prepare a query statement

Parameters
string$queryQuery to prepare
Returns
Doctrine_Adapter_Statement_Oracle $stmt prepared statement

Definition at line 144 of file Oracle.php.

{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode);
return $stmt;
}
Doctrine_Adapter_Oracle::query (   $query)

Execute query and return results as statement object

Parameters
string$query
Returns
Doctrine_Adapter_Statement_Oracle $stmt

Definition at line 157 of file Oracle.php.

{
$stmt = new Doctrine_Adapter_Statement_Oracle($this, $query, $this->executeMode);
$stmt->execute();
return $stmt;
}
Doctrine_Adapter_Oracle::quote (   $input)

Quote a value for the dbms

Parameters
string$input
Returns
string $quoted

Definition at line 171 of file Oracle.php.

{
return "'" . str_replace("'","''",$input) . "'";
}
Doctrine_Adapter_Oracle::rollBack ( )

Rollback a transaction

Returns
boolean

Definition at line 227 of file Oracle.php.

{
return @oci_rollback($this->connection);
}
Doctrine_Adapter_Oracle::setAttribute (   $attribute,
  $value 
)

Set connection attribute

Parameters
integer$attribute
mixed$valuethe value of given attribute
Returns
boolean Returns TRUE on success or FALSE on failure.

Definition at line 239 of file Oracle.php.

{
switch ($attribute) {
case Doctrine_Core::ATTR_DRIVER_NAME:
//TODO throw an error since driver name can not be changed
case Doctrine_Core::ATTR_ERRMODE:
break;
case Doctrine_Core::ATTR_CASE:
if ($value == Doctrine_Core::CASE_NATURAL) {
break;
} else {
throw new Doctrine_Adapter_Exception("Unsupported Option for ATTR_CASE: $value");
}
default:
throw new Doctrine_Adapter_Exception("Unsupported Attribute: $attribute");
return false;
}
$this->attributes[$attribute] = $value;
return true;
}

Field Documentation

Doctrine_Adapter_Oracle::$connection = false
protected

Resource representing connection to database

Definition at line 46 of file Oracle.php.

Doctrine_Adapter_Oracle::$executeMode = OCI_COMMIT_ON_SUCCESS
protected

execution mode

Definition at line 41 of file Oracle.php.


The documentation for this class was generated from the following file: