Skip to content

Commit

Permalink
Merge pull request doctrine#6257 from weaverryan/add-criteria-note
Browse files Browse the repository at this point in the history
Adding a note about the `Doctrine\ORM\QueryBuilder#addCriteria()` method
  • Loading branch information
Ocramius authored Jan 25, 2017
2 parents 9c76c37 + 63bd6c3 commit 888f1be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions docs/en/reference/query-builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,24 @@ complete list of supported helper methods available:
public function countDistinct($x); // Returns Expr\Func
}
Adding a Criteria to a Query
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You can also add a :ref:`Criteria <filtering-collections>` to a QueryBuilder by
using ``addCriteria``:

.. code-block:: php
<?php
use Doctrine\Common\Collections\Criteria;
// ...
$criteria = Criteria::create()
->orderBy(['firstName', 'ASC']);
// $qb instanceof QueryBuilder
$qb->addCriteria($criteria);
// then execute your query like normal
Low Level API
^^^^^^^^^^^^^
Expand Down
4 changes: 2 additions & 2 deletions docs/en/reference/working-with-associations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,11 @@ address reference. When flush is called not only are the references removed
but both the old standing data and the one address entity are also deleted
from the database.

.. _filtering-collections:

Filtering Collections
---------------------

.. filtering-collections:
Collections have a filtering API that allows to slice parts of data from
a collection. If the collection has not been loaded from the database yet,
the filtering API can work on the SQL level to make optimized access to
Expand Down

0 comments on commit 888f1be

Please sign in to comment.