From 2f72219d6ef87f2b2cc7db2bc4f455cc40fc0390 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 1 Aug 2012 22:15:44 +0200 Subject: [PATCH] Finish first version of filtering api documentation --- en/reference/working-with-associations.rst | 31 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/en/reference/working-with-associations.rst b/en/reference/working-with-associations.rst index fee7d6731..2781d5cd1 100644 --- a/en/reference/working-with-associations.rst +++ b/en/reference/working-with-associations.rst @@ -627,13 +627,21 @@ large collections. $group = $entityManager->find('Group', $groupId); $userCollection = $group->getUsers(); - $expr = $userCollection->getExpressionBuilder(); - $criteria = Criteria::create(); - $criteria->where($expr->eq("birthday", "1982-02-17")); + $criteria = Criteria::create() + ->where(Criteria::expr()->eq("birthday", "1982-02-17")) + ->orderBy(array("username" => "ASC")) + ->setFirstResult(0) + ->setMaxResults(20) + ; $birthdayUsers = $userCollection->matching($criteria); +.. tip:: + + You can move the access of slices of collections into dedicated methods of + an entity. For example ``Group#getTodaysBirthdayUsers()``. + The Criteria has a limited matching language that works both on the SQL and on the PHP collection level. This means you can use collection matching interchangeably, independent of in-memory or sql-backed collections. @@ -686,4 +694,19 @@ interchangeably, independent of in-memory or sql-backed collections. public function getMaxResults(); } -You can build expressions through the ExpressionBuilder +You can build expressions through the ExpressionBuilder. It has the following +methods: + +* ``andX($arg1, $arg2, ...)`` +* ``orX($arg1, $arg2, ...)`` +* ``eq($field, $value)`` +* ``gt($field, $value)`` +* ``lt($field, $value)`` +* ``lte($field, $value)`` +* ``gte($field, $value)`` +* ``neq($field, $value)`` +* ``isNull($field)`` +* ``in($field, array $values)`` +* ``notIn($field, array $values)`` + +