How to debug Database Update Queries

How do i debug an update-query as seen here:

$bool = Db::update('users', ['username' => 'zoe'], ['username' => 'moe']);
dump($bool);

As i see it a can only get true or false as a result, but how do i see what the error was if it fails?

THX!

1 Like

since i could not find an instance-method called “update” i am using the static class method. this is my working solution but it does not feel “right”. Maybe there’s a more elegant way?

$db = Database::instance();
$success = Db::update(static::TABLE, $data, ['kirby_slug' => $this->slug()]);
if (!$success) {
    $exception = $db->lastError();
    throw $exception;
}