Skip to content

Commit

Permalink
Do not buffer results for non-SELECT statements (insert, update, delete)
Browse files Browse the repository at this point in the history
  • Loading branch information
snelg committed Jan 21, 2016
1 parent afbdfc7 commit 626302a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Driver/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

use Cake\Database\Driver;
use Cake\Database\Driver\PDODriverTrait;
use Cake\Database\Query;
use Cake\Database\Statement\PDOStatement;
use Cake\Oracle\Dialect\OracleDialectTrait;
use Cake\Oracle\Schema\OracleSchema;
use Cake\Oracle\Statement\Oci8Statement;
use Cake\Oracle\Statement\OracleStatement;
use Cake\ORM\Query;
use PDO;
use yajra\Pdo\Oci8;

Expand Down Expand Up @@ -97,15 +97,17 @@ public function connect()
public function prepare($query)
{
$this->connect();
$isObject = ($query instanceof Query) || ($query instanceof \Cake\Database\Query);
$isObject = ($query instanceof Query);
$queryStringRaw = $isObject ? $query->sql() : $query;
$queryString = $this->_fromDualIfy($queryStringRaw);
$yajraStatement = $this->_connection->prepare($queryString);
$oci8Statement = new Oci8Statement($yajraStatement); //Need to override some un-implemented methods in yajra Oci8 "Statement" class
$statement = new OracleStatement(new PDOStatement($oci8Statement, $this), $this); //And now wrap in a Cake-ified, bufferable Statement
$statement->queryString = $queryStringRaw; //Oci8PDO does not correctly set read-only $queryString property, so we have a manual override
if ($isObject && $query->bufferResults() === false) {
$statement->bufferResults(false);
if ($isObject) {
if ($query->bufferResults() === false || $query->type() != 'select') {
$statement->bufferResults(false);
}
}
return $statement;
}
Expand Down

0 comments on commit 626302a

Please sign in to comment.