Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #143 from atk4/feature/resource-support
Browse files Browse the repository at this point in the history
replace bindValue to bindParam and use trick for LOBs
  • Loading branch information
romaninsh committed Apr 19, 2018
2 parents f332a29 + e071898 commit 3737316
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ class Expression implements \ArrayAccess, \IteratorAggregate
*/
public $connection = null;

/**
* Holds references to bound parameter values.
*
* This is needed to use bindParam instead of bindValue and to be able to use 4th parameter of bindParam.
*
* @var array
*/
private $boundValues = [];

/**
* Specifying options to constructors will override default
* attribute values of this class.
Expand Down Expand Up @@ -570,7 +579,15 @@ public function execute($connection = null)
]);
}

if (!$statement->bindValue($key, $val, $type)) {
// Workaround to support LOB data type. See https://github.com/doctrine/dbal/pull/2434
$this->boundValues[$key] = $val;
if ($type === \PDO::PARAM_STR) {
$bind = $statement->bindParam($key, $this->boundValues[$key], $type, strlen($val));
} else {
$bind = $statement->bindParam($key, $this->boundValues[$key], $type);
}

if (!$bind) {
throw new Exception([
'Unable to bind parameter',
'param' => $key,
Expand Down

0 comments on commit 3737316

Please sign in to comment.