Skip to content

Commit

Permalink
Merge pull request #5 from woytam/patch-1
Browse files Browse the repository at this point in the history
 Execute() bindings of array of values
  • Loading branch information
filisko authored Jan 5, 2020
2 parents 1a102a6 + 77a7a93 commit e6222c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,15 @@ public function execute($input_parameters = null)

$bindings = $this->bindings;
$statement = $this->PDOStatement->queryString;
$indexed = ($bindings == array_values($bindings));
foreach ($bindings as $param => $value) {
$value = (is_numeric($value) or is_null($value)) ? $value : $this->pdo->quote($value);
$value = is_null($value) ? "null" : $value;
$statement = preg_replace("/$param(?![a-zA-Z])/", $value, $statement);
if ($indexed) {
$statement = preg_replace('/\?/', $value, $statement, 1);
} else {
$statement = str_replace(":$param", $value, $statement);
}
}

$start = microtime(true);
Expand Down

0 comments on commit e6222c8

Please sign in to comment.