Skip to content

Commit

Permalink
adding access to oci8 resources
Browse files Browse the repository at this point in the history
  • Loading branch information
jfelder committed Mar 25, 2014
1 parent 119c88c commit 3c5dbda
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Jfelder/OracleDB/OCI_PDO/OCI.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,16 @@ public function getExecuteMode()
return $this->mode;
}

/**
* Returns the oci8 connection handle for use with other oci_ functions
*
* @return oci8 The oci8 connection handle
*/
public function getOCIResource()
{
return $this->conn;
}

/**
* Set the PDO errorInfo array values
*
Expand Down
14 changes: 13 additions & 1 deletion src/Jfelder/OracleDB/OCI_PDO/OCIStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OCIStatement extends \PDOStatement
\PDO::PARAM_NULL => \SQLT_INT,
\PDO::PARAM_INT => \SQLT_INT,
\PDO::PARAM_STR => \SQLT_CHR,
\PDO::PARAM_INPUT_OUTPUT => \SQLT_CHR,
);

/**
Expand Down Expand Up @@ -142,7 +143,7 @@ public function bindParam ($parameter , &$variable, $data_type = \PDO::PARAM_STR
$this->addParameter($parameter, $variable, $data_type, $length, $driver_options);

if(!isset($this->datatypes[$data_type])) {
if($data_type == \PDO::PARAM_INT|\PDO::PARAM_INPUT_OUTPUT) {
if($data_type === (\PDO::PARAM_INT|\PDO::PARAM_INPUT_OUTPUT)) {
$data_type = \PDO::PARAM_STR;
$length = $length > 40 ? $length : 40;
} else {
Expand Down Expand Up @@ -477,6 +478,17 @@ private function addParameter($parameter , $variable, $data_type = \PDO::PARAM_S
);
}

/**
* Returns the oci8 statement handle for use with other oci_ functions
*
* @return oci8 statment The oci8 statment handle
*/
public function getOCIResource()
{
return $this->stmt;
}


/**
* Single location to process all the bindings on a resultset
*
Expand Down
9 changes: 7 additions & 2 deletions tests/OracleDBOCIStatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp()
$OCIBindChangeStatus = false;

$this->oci = m::mock(new \TestOCIStub('', null, null, array(\PDO::ATTR_CASE => \PDO::CASE_LOWER)));
$this->stmt = m::mock(new \TestOCIStatementStub('oci statement', $this->oci, '', array('fake'=>'attribute')));
$this->stmt = m::mock(new \TestOCIStatementStub('oci8 statement', $this->oci, '', array('fake'=>'attribute')));

//fake result sets for all the fetch calls
$this->resultUpperArray = array('FNAME' => 'Test', 'LNAME' => 'Testerson', 'EMAIL' => '[email protected]');
Expand Down Expand Up @@ -123,7 +123,7 @@ public function testBindColumnWithInvalidDataType ()
{
$stmt = new \TestOCIStatementStub('oci8 statement', $this->oci, 'sql', array());
$holder = "";
$stmt->bindColumn(1, $holder, \PDO::PARAM_INPUT_OUTPUT);
$stmt->bindColumn(1, $holder, -5);
}

public function testBindColumnSuccess ()
Expand Down Expand Up @@ -471,5 +471,10 @@ public function testSetFetchMode ()
{
$this->assertTrue($this->stmt->setFetchMode(\PDO::FETCH_CLASS));
}

public function testGetOCIResource()
{
$this->assertEquals('oci8 statement', $this->stmt->getOCIResource());
}
}
}
5 changes: 5 additions & 0 deletions tests/OracleDBOCITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ public function testGetExecuteMode()
$this->assertEquals(\OCI_COMMIT_ON_SUCCESS, $this->oci->getExecuteMode());
}

public function testGetOCIResource()
{
$this->assertEquals('oci8', $this->oci->getOCIResource());
}

public function testSetExecuteModeWithValidMode()
{
$this->oci->setExecuteMode(\OCI_COMMIT_ON_SUCCESS);
Expand Down

0 comments on commit 3c5dbda

Please sign in to comment.