Skip to content

Commit

Permalink
Merge pull request #16 from derflocki/fix-ORA-01000
Browse files Browse the repository at this point in the history
fix a possible "ORA-01000: maximum open cursors exceeded" when many n…
  • Loading branch information
j0k3r committed May 20, 2016
2 parents 7abe498 + f50e3a3 commit 3835027
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/Doctrine/Adapter/Statement/Oracle.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ public function bindParam($column, &$variable, $type = null, $length = null, $dr
public function closeCursor()
{
$this->bindParams = array();
return oci_free_statement($this->statement);
if (is_resource($this->statement)) {
return oci_free_statement($this->statement);
}
return true;
}

/**
Expand Down
15 changes: 14 additions & 1 deletion lib/Doctrine/Connection/Statement.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ public function __construct(Doctrine_Connection $conn, $stmt)
throw new Doctrine_Exception('Unknown statement object given.');
}
}

/**
* destructor
*
* make sure that the cursor is closed
*
*/
public function __destruct()
{
$this->closeCursor();
}
/**
* getConnection
* returns the connection object this statement uses
Expand Down Expand Up @@ -261,6 +270,10 @@ public function execute($params = null)

$this->_conn->getListener()->postStmtExecute($event);

//fix a possible "ORA-01000: maximum open cursors exceeded" when many non-SELECTs are executed and the profiling is enabled
if (strtoupper(substr($this->_stmt->queryString,0,6)) != 'SELECT' && strtoupper(substr($this->_stmt->queryString,0,4)) != 'WITH' ){
$this->closeCursor();
}
return $result;
} catch (PDOException $e) {
} catch (Doctrine_Adapter_Exception $e) {
Expand Down

0 comments on commit 3835027

Please sign in to comment.