Skip to content

Commit

Permalink
atualizacao
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobmorais committed Feb 19, 2023
1 parent a6b6a23 commit e143476
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Crud.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,17 @@ public function update(string $fields, array $values = null, string $where = nul
* @param string $where
* @return bool
*/
public function updateArray(array $params, string $where = ""): bool
public function updateArray(array $params, string $where): bool
{
if (!empty($params)) {
$query = "UPDATE {$this->tableName} SET";
$values = [];

foreach ($params as $index => $column) {
$query .= " {$index} = ?, ";
$values[] = $params[$index];
if (!empty($params[$index])) {
$query .= " {$index} = ?, ";
$values[] = $params[$index];
}
}
$query = rtrim($query, ", ");

Expand Down

0 comments on commit e143476

Please sign in to comment.