summaryrefslogtreecommitdiff
path: root/vendor/doctrine/collections/docs/en/expressions.rst
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/doctrine/collections/docs/en/expressions.rst')
-rw-r--r--vendor/doctrine/collections/docs/en/expressions.rst117
1 files changed, 117 insertions, 0 deletions
diff --git a/vendor/doctrine/collections/docs/en/expressions.rst b/vendor/doctrine/collections/docs/en/expressions.rst
new file mode 100644
index 0000000..5587bfb
--- /dev/null
+++ b/vendor/doctrine/collections/docs/en/expressions.rst
@@ -0,0 +1,117 @@
1Expressions
2===========
3
4The ``Doctrine\Common\Collections\Expr\Comparison`` class
5can be used to create comparison expressions to be used with the
6``Doctrine\Common\Collections\Criteria`` class. It has the
7following operator constants:
8
9- ``Comparison::EQ``
10- ``Comparison::NEQ``
11- ``Comparison::LT``
12- ``Comparison::LTE``
13- ``Comparison::GT``
14- ``Comparison::GTE``
15- ``Comparison::IS``
16- ``Comparison::IN``
17- ``Comparison::NIN``
18- ``Comparison::CONTAINS``
19- ``Comparison::MEMBER_OF``
20- ``Comparison::STARTS_WITH``
21- ``Comparison::ENDS_WITH``
22
23The ``Doctrine\Common\Collections\Expr\CompositeExpression`` class
24can be used to create composite expressions to be used with the
25``Doctrine\Common\Collections\Criteria`` class. It has the
26following operator constants:
27
28- ``CompositeExpression::TYPE_AND``
29- ``CompositeExpression::TYPE_OR``
30- ``CompositeExpression::TYPE_NOT``
31
32When using the ``TYPE_OR`` and ``TYPE_AND`` operators the
33``CompositeExpression`` accepts multiple expressions as parameter
34but only one expression can be provided when using the ``NOT`` operator.
35
36The ``Doctrine\Common\Collections\Criteria`` class has the following
37API to be used with expressions:
38
39where
40-----
41
42Sets the where expression to evaluate when this Criteria is searched for.
43
44.. code-block:: php
45 $expr = new Comparison('key', Comparison::EQ, 'value');
46
47 $criteria->where($expr);
48
49andWhere
50--------
51
52Appends the where expression to evaluate when this Criteria is searched for
53using an AND with previous expression.
54
55.. code-block:: php
56 $expr = new Comparison('key', Comparison::EQ, 'value');
57
58 $criteria->andWhere($expr);
59
60orWhere
61-------
62
63Appends the where expression to evaluate when this Criteria is searched for
64using an OR with previous expression.
65
66.. code-block:: php
67 $expr1 = new Comparison('key', Comparison::EQ, 'value1');
68 $expr2 = new Comparison('key', Comparison::EQ, 'value2');
69
70 $criteria->where($expr1);
71 $criteria->orWhere($expr2);
72
73orderBy
74-------
75
76Sets the ordering of the result of this Criteria.
77
78.. code-block:: php
79 use Doctrine\Common\Collections\Order;
80
81 $criteria->orderBy(['name' => Order::Ascending]);
82
83setFirstResult
84--------------
85
86Set the number of first result that this Criteria should return.
87
88.. code-block:: php
89 $criteria->setFirstResult(0);
90
91getFirstResult
92--------------
93
94Gets the current first result option of this Criteria.
95
96.. code-block:: php
97 $criteria->setFirstResult(10);
98
99 echo $criteria->getFirstResult(); // 10
100
101setMaxResults
102-------------
103
104Sets the max results that this Criteria should return.
105
106.. code-block:: php
107 $criteria->setMaxResults(20);
108
109getMaxResults
110-------------
111
112Gets the current max results option of this Criteria.
113
114.. code-block:: php
115 $criteria->setMaxResults(20);
116
117 echo $criteria->getMaxResults(); // 20