id = $row['id']; $model->name = $row['name']; $model->setPassword($row['password']); $model->enabled = $row['enabled'] != 0; return $model; } public function save(Model $model): bool { if (isset($model->id)) { $qb = $this->connection->createQueryBuilder() ->insert($this->table) ->values([ 'name' => $model->name, 'password' => $model->getPassword(), 'enabled' => $model->enabled ? 1 : 0 ]); return $this->connection->executeStatement($qb) > 0; } $qb = $this->connection->createQueryBuilder() ->update($this->table) ->set('name', $model->name) ->set('password', $model->getPassword()) ->set('enabled', $model->enabled ? 1 : 0) ->where('id = ?'); return $this->connection->executeStatement($qb, [$model->id]) > 0; } public function fetchByName(string $name): UserModel|bool { $qb = $this->connection->createQueryBuilder() ->select('*') ->from($this->table) ->where('name = ?'); return $this->load( $this->connection ->executeQuery($qb, [$name]) ->fetchAssociative() ); } }