Skip to content

Commit

Permalink
chore: update db
Browse files Browse the repository at this point in the history
  • Loading branch information
mychidarko committed Oct 19, 2024
1 parent 6cef68d commit 2e9bf9a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Db.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ public function where($condition, $comparator = null, $value = null): self
$value === null ? $comparator : $value,
$value === null ? "=" : $comparator
);

$this->bind(...(Builder::$bindings));

return $this;
Expand Down Expand Up @@ -397,23 +398,25 @@ public function rollback(): self
}

/**
* Transaction shorthand
* Run a database transaction
*
* @param callable $callback The callback to run
* @return self
*
* @return boolean Whether the transaction completed successfully
*/
public function transaction($callback): self
public function transaction($callback): bool
{
try {
$this->beginTransaction();
$callback($this);
$this->commit();

return true;
} catch (\Exception $e) {
$this->rollback();
$this->errorsArray = $e;

throw $e;
return false;
}

return $this;
}
}

0 comments on commit 2e9bf9a

Please sign in to comment.