diff --git a/lib/Doctrine/Adapter/Statement/Oracle.php b/lib/Doctrine/Adapter/Statement/Oracle.php index 3afca3e4b..302c1381b 100644 --- a/lib/Doctrine/Adapter/Statement/Oracle.php +++ b/lib/Doctrine/Adapter/Statement/Oracle.php @@ -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; } /** diff --git a/lib/Doctrine/Connection/Statement.php b/lib/Doctrine/Connection/Statement.php index ccbec132b..edeea5b51 100644 --- a/lib/Doctrine/Connection/Statement.php +++ b/lib/Doctrine/Connection/Statement.php @@ -59,7 +59,15 @@ 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 @@ -261,13 +269,19 @@ public function execute($params = null) $this->_conn->getListener()->postStmtExecute($event); - return $result; } catch (PDOException $e) { + $result = false; + $this->_conn->rethrowException($e, $this); } catch (Doctrine_Adapter_Exception $e) { + $result = false; + $this->_conn->rethrowException($e, $this); + } finally { + //fix a possible "ORA-01000: maximum open cursors exceeded" when many non-SELECTs are executed + if (strtoupper(substr($this->_stmt->queryString,0,6)) != 'SELECT' && strtoupper(substr($this->_stmt->queryString,0,4)) != 'WITH' ){ + $this->closeCursor(); + } + return $result; } - - $this->_conn->rethrowException($e, $this); - return false; }