src/Koldy/Db/Query/Select.php
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();
    }
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();
    }
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 ( ) ; }
Fetch all records from the executed SELECT statement and get the Generator back.

@param string|null $class the name of class on which you want the instance of - class has to be able to accept array in constructor

@return Generator
@throws Exception
@throws \Koldy\Exception
Fetch all records from the executed SELECT statement and get the Generator back .