Added createQueryBuilder() method to the Document Repository #196

Merged
merged 2 commits into from Dec 9, 2012

2 participants

@dantleech

Hi,

Ive added a createQueryBuilder method to the Document repository, it returns the query builder with the "from" and "phpcr:class = 'FQN'" stuff preloaded. So it acts like the Doctrine ORM.

This is going to go a little wrong as soon as somebody trys to:

$qb = $myRepo->createQueryBuilder();
$qb->where(...); // and so delete the "andWhere('phpcr:class = FQN);

So people will need to remember to use "andWhere"

dantleech Added createQueryBuilder() method to Doc manager
- As with the ORM this method creates a query builder pre loaded with
  the source
f991faf
@dbu dbu commented on an outdated diff Dec 9, 2012
lib/Doctrine/ODM/PHPCR/DocumentRepository.php
@@ -276,4 +276,23 @@ public function getDocumentsByQuery(\PHPCR\Query\QueryInterface $query)
{
return $this->dm->getDocumentsByQuery($query, $this->className);
}
+
+ /**
+ * Return a pre-configured query builder instance
@dbu
Doctrine member
dbu added a line comment Dec 9, 2012

you could add the comment from the PR about not using ->where() but ->andWhere to the docblock here.

@dbu
Doctrine member
dbu added a line comment Dec 9, 2012

and be explicit that its a query builder to find documents of the class this repository is for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dbu
Doctrine member
dbu commented Dec 9, 2012

thanks for this PR, great to see those small tweaks and improvements! can you improve the docblock (even if we afterwards document it well, some people will just see the code and not read the doc :-)

@dantleech

ok, improved the doc block.

@dbu dbu merged commit d794314 into doctrine:master Dec 9, 2012
@dbu
Doctrine member
dbu commented Dec 9, 2012

great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment