1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-13 02:04:35 +02:00

Fix in DatabaseQuery::getDebugQuery()

This commit is contained in:
Ryan Cramer
2020-05-29 15:41:52 -04:00
parent f307d375f1
commit 9b43b4fb96

View File

@@ -120,7 +120,8 @@ abstract class DatabaseQuery extends WireData {
* Get or set a bind option
*
* @param string|bool $optionName One of 'prefix' or 'global', boolean true to get/set all
* @param null|int|string|array $optionValue Omit when getting, Specify option value to set, or array when setting all
* @param null|int|string|array $optionValue Omit when getting, Specify option value to set, or array when setting
* all
* @return string|int|array
* @since 3.0.157
*
@@ -597,9 +598,11 @@ abstract class DatabaseQuery extends WireData {
public function getDebugQuery() {
$sql = $this->getQuery();
$suffix = $this->bindOptions['suffix'];
$database = $this->wire('database');
foreach($this->bindValues as $bindKey => $bindValue) {
if(is_string($bindValue)) $bindValue = $database->quote($bindValue);
if($bindKey[strlen($bindKey)-1] === $suffix) {
$sql = str_replace($bindKey, $bindValue);
$sql = str_replace($bindKey, $bindValue, $sql);
} else {
$sql = preg_replace('/' . $bindKey . '\b/', $bindValue, $sql);
}