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
Create queryBuilder from parts. #556
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,6 +351,28 @@ public function createQueryBuilder() | |
return new QueryBuilder($this); | ||
} | ||
|
||
/** | ||
* Create a QueryBuilder instance from DQL parts | ||
* | ||
* @param array $parts | ||
* | ||
* @return QueryBuilder | ||
*/ | ||
public function setDQLParts(array $parts = array()) | ||
{ | ||
$queryBuilder = new QueryBuilder($this); | ||
foreach ($parts as $name => $part) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline before this |
||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please fix CS: newlines around logical blocks and PSR-2 generally |
||
if ($part) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are empty parts even allowed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getDQLParts returns an array of all parts. It can have keys with an empty value. |
||
if (is_array($part) && $name != 'join') { | ||
$part = current($part); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be |
||
} | ||
$queryBuilder->add($name, $part); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline before this call |
||
} | ||
} | ||
return $queryBuilder; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing newline before |
||
} | ||
|
||
/** | ||
* Flushes all changes to objects that have been queued up to now to the database. | ||
* This effectively synchronizes the in-memory state of managed objects with the | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What? Is this a joke? EntityManager::setDQLParts? EM doesn't have any DQL parts…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch! I really was thinking he applied the changes to the QueryBuilder.