public function fetchAllObjGenerator(string $class = null): Generator
    {
        if (!$this->wasExecuted()) {
            $this->exec();
        }

        $statement = $this->getAdapter()->getStatement();

        if ($class === null) {
            while ($record = $statement->fetch(PDO::FETCH_OBJ)) {
                yield $record;
            }
        } else {
            while ($record = $statement->fetch(PDO::FETCH_ASSOC)) {
                yield new $class($record);
            }
        }

        $statement->closeCursor();
    }