From 426168be7e92b09953aa0c2b737586708425ca4f Mon Sep 17 00:00:00 2001 From: Glen Sawyer Date: Wed, 27 Jan 2016 12:31:43 -0700 Subject: [PATCH] Ensure bound variables remain active until after execute --- src/Statement/Oci8Statement.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Statement/Oci8Statement.php b/src/Statement/Oci8Statement.php index 0d2a2b6..50cdfd0 100644 --- a/src/Statement/Oci8Statement.php +++ b/src/Statement/Oci8Statement.php @@ -8,6 +8,8 @@ */ class Oci8Statement extends Statement { + protected $preserveBindings = []; + /** * {@inheritDoc} */ @@ -30,6 +32,21 @@ public function closeCursor() } $success = oci_free_statement($this->_sth); $this->_sth = null; + $this->preserveBindings = []; return $success; } + + /** + * {@inheritDoc} + */ + public function bindValue($parameter, $variable, $dataType = PDO::PARAM_STR) + { + /* PHP 7 apparently cleans up bound variables before we get back to + * oci_execute. But oci_bind_by_name binds variables by reference. + * We need to make sure the actual referenced $variable remains + * active until later, so we just toss it onto a pile here + */ + $this->preserveBindings[] = &$variable; + return $this->bindParam($parameter, $variable, $dataType); + } }