Skip to content

Update doctrine.rst #8949

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

Merged
merged 1 commit into from
Jan 2, 2018
Merged
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
4 changes: 3 additions & 1 deletion doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ a new method for this to your repository::
return $qb->execute();

// to get just one result:
// $product = $query->setMaxResults(1)->getOneOrNullResult();
// $product = $qb->setMaxResults(1)->getOneOrNullResult();
}
}

Expand Down Expand Up @@ -654,6 +654,8 @@ In addition to the query builder, you can also query with `Doctrine Query Langua

public function findAllGreaterThanPrice($price): array
{
$em = $this->getEntityManager();

$query = $em->createQuery(
Copy link
Member

Choose a reason for hiding this comment

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

I think we could just use $this->_em here instead.

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'm not sure if this is a good idea, since $this->_em has never been introduced before. Without you mentioning it I wouldn't know it existed. The other code example in the same section doesn't use it as well.

Copy link
Member

Choose a reason for hiding this comment

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

That's true! And in the example below, we use $conn = $this->getEntityManager()->getConnection();

Copy link
Member

Choose a reason for hiding this comment

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

Let's merge this "as is" ... and later we can think of explaining $this->_em somewhere and using it in all examples.

'SELECT p
FROM App\Entity\Product p
Expand Down