PHP Classes

File: src/vendor/doctrine/collections/docs/en/lazy-collections.rst

Recommend this page to a friend!
  Classes of walid laggoune   QPHP   src/vendor/doctrine/collections/docs/en/lazy-collections.rst   Download  
File: src/vendor/doctrine/collections/docs/en/lazy-collections.rst
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: QPHP
Exchange messages with a queue server using Swoole
Author: By
Last change:
Date: 2 years ago
Size: 740 bytes
 

Contents

Class file image Download
Lazy Collections ================ To create a lazy collection you can extend the ``Doctrine\Common\Collections\AbstractLazyCollection`` class and define the ``doInitialize`` method. Here is an example where we lazily query the database for a collection of user records: .. code-block:: php use Doctrine\DBAL\Connection; class UsersLazyCollection extends AbstractLazyCollection { /** @var Connection */ private $connection; public function __construct(Connection $connection) { $this->connection = $connection; } protected function doInitialize() : void { $this->collection = $this->connection->fetchAll('SELECT * FROM users'); } }