Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a note about the Doctrine\ORM\QueryBuilder#addCriteria() method #6257

Merged
merged 1 commit into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
---------------------
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the _ was left off accidentally before - I'm not familiar with this syntax without an underscore, and I searched the codebase and found NO other references like this (git grep '\.\. ' | grep -v 'code-block' | grep -v 'note' | grep -v 'section' | grep -v '\.\. _' | grep -v 'configuration-block' | grep -v versionadded | grep -v 'warning' | grep -v '//' | grep -v '\-\->' | grep -v 'include' | grep -v 'caution' | less gets you a short list, where you can see this). Also, this section header already gave us a #filtering-collections anchor, even without the added reference.


.. 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