From 404b1b056479dce4c1fd1828c4bdf294530447e1 Mon Sep 17 00:00:00 2001 From: Anton M Date: Wed, 27 Feb 2019 20:50:58 +0200 Subject: [PATCH] fix a problem with preg_replace parameters in the query If one of parameters have a `?` symbol in the text, `preg_replace` can work incorrectly, because just looking for any `?` symbol --- src/ClickHouseStatement.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ClickHouseStatement.php b/src/ClickHouseStatement.php index 9587257..fd0d708 100644 --- a/src/ClickHouseStatement.php +++ b/src/ClickHouseStatement.php @@ -292,8 +292,8 @@ public function execute($params = null) : bool } else { foreach (array_keys($this->values) as $key) { $sql = preg_replace( - '/(' . (is_int($key) ? '\?' : ':' . $key) . ')/i', - $this->getTypedParam($key), + '/(' . (is_int($key) ? '\?([,\)])' : ':' . $key) . ')/i', + $this->getTypedParam($key).'$2', $sql, 1 );