From e14b724dd79694b4ca9a28e0d903781bac31c4d8 Mon Sep 17 00:00:00 2001 From: Arif Hoque Date: Wed, 11 Mar 2026 15:53:36 +0600 Subject: [PATCH] fix: updateColumn() / increment() / decrement() use buildWhereClause() instead of legacy condition loop --- src/Phaseolies/Database/Entity/Builder.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Phaseolies/Database/Entity/Builder.php b/src/Phaseolies/Database/Entity/Builder.php index 57e960a..ddf4fa5 100644 --- a/src/Phaseolies/Database/Entity/Builder.php +++ b/src/Phaseolies/Database/Entity/Builder.php @@ -2743,24 +2743,23 @@ protected function updateColumn(string $column, int $amount, string $operator, a $sql .= ', ' . implode(', ', $extraUpdates); } - if (!empty($this->conditions)) { - $conditionStrings = []; - foreach ($this->conditions as $condition) { - $conditionStrings[] = "{$condition[1]} {$condition[2]} ?"; - $bindings[] = $condition[3]; - } - $sql .= ' WHERE ' . implode(' ', $this->formatConditions($conditionStrings)); + [$whereSql, $whereBindings] = $this->buildWhereClause(); + if ($whereSql) { + $sql .= ' WHERE ' . $whereSql; } try { $stmt = $this->pdo->prepare($sql); - foreach ($bindings as $index => $value) { - $stmt->bindValue($index + 1, $value, $this->getPdoParamType($value)); + $index = 1; + foreach ($bindings as $value) { + $stmt->bindValue($index++, $value, $this->getPdoParamType($value)); + } + foreach ($whereBindings as $value) { + $stmt->bindValue($index++, $value, $this->getPdoParamType($value)); } $stmt->execute(); - return $stmt->rowCount(); } catch (PDOException $e) { throw new PDOException("Database error: " . $e->getMessage());