You can create custom collection classes by extending the
+Doctrine\Common\Collections\ArrayCollection class. If the
+__construct semantics are different from the default ArrayCollection
+you can override the createFrom method:
The Doctrine\Common\Collections\Expr\Comparison class
+can be used to create comparison expressions to be used with the
+Doctrine\Common\Collections\Criteria class. It has the
+following operator constants:
+
+
Comparison::EQ
+
Comparison::NEQ
+
Comparison::LT
+
Comparison::LTE
+
Comparison::GT
+
Comparison::GTE
+
Comparison::IS
+
Comparison::IN
+
Comparison::NIN
+
Comparison::CONTAINS
+
Comparison::MEMBER_OF
+
Comparison::STARTS_WITH
+
Comparison::ENDS_WITH
+
+
The Doctrine\Common\Collections\Expr\CompositeExpression class
+can be used to create composite expressions to be used with the
+Doctrine\Common\Collections\Criteria class. It has the
+following operator constants:
+
+
CompositeExpression::TYPE_AND
+
CompositeExpression::TYPE_OR
+
CompositeExpression::TYPE_NOT
+
+
When using the TYPE_OR and TYPE_AND operators the
+CompositeExpression accepts multiple expressions as parameter
+but only one expression can be provided when using the NOT operator.
+
The Doctrine\Common\Collections\Criteria class has the following
+API to be used with expressions:
Doctrine Collections is a library that contains classes for working with
+arrays of data. Here is an example using the simple
+Doctrine\Common\Collections\ArrayCollection class:
Doctrine Collections provides an interface named Doctrine\Common\Collections\Collection
+that resembles the nature of a regular PHP array. That is,
+it is essentially an ordered map that can also be used
+like a list.
+
A Collection has an internal iterator just like a PHP array. In addition,
+a Collection can be iterated with external iterators, which is preferable.
+To use an external iterator simply use the foreach language construct to
+iterate over the collection, which calls getIterator() internally, or
+explicitly retrieve an iterator though getIterator() which can then be
+used to iterate over the collection. You can not rely on the internal iterator
+of the collection being at a certain position unless you explicitly positioned it before.
+
Methods that do not alter the collection or have template types
+appearing in invariant or contravariant positions are not directly
+defined in Doctrine\Common\Collections\Collection, but are inherited
+from the Doctrine\Common\Collections\ReadableCollection interface.
Gets the index/key of a given element. The comparison of two elements is strict, that means not only the value but also the type must match. For objects this means reference equality.
Extracts a slice of $length elements starting at position $offset from the Collection. If $length is null it returns all elements from $offset to the end of the Collection. Keys have to be preserved by this method. Calling this method will only return the selected slice and NOT change the elements contained in the collection slice is called on.
Some Doctrine Collections, like Doctrine\Common\Collections\ArrayCollection,
+implement an interface named Doctrine\Common\Collections\Selectable
+that offers the usage of a powerful expressions API, where conditions
+can be applied to a collection to get a result with matching elements
+only.
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:
Using (un-)serialize() on a collection is not a supported use-case
+and may break when changes on the collection's internals happen in the future.
+If a collection needs to be serialized, use toArray() and reconstruct
+the collection manually.
A reconstruction is also necessary when the collection contains objects with
+infinite recursion of dependencies like in this json_serialize() example:
The QueryBuilder is not an abstraction of DQL, but merely a tool to dynamically build it.
You should still use plain DQL when you can, as it is simpler and more readable.
-More about this in the 750f5826a69367a5e1dcee81fc4d711492268c99.
+More about this in the 71b43a4f56540dd6349c7d0557bc7b9fa076e90b.