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

Improved DQL's "new" operator documentation #915

Merged
merged 2 commits into from
Jan 25, 2014

Conversation

mnapoli
Copy link
Contributor

@mnapoli mnapoli commented Jan 21, 2014

I had to dig through the pull requests and issues to figure that out, so I believe it's best documented explicitly.

I had to dig through the pull requests and issues to figure that out, so I believe it's best documented explicitly.
@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-2928

We use Jira to track the state of pull requests and the versions they got
included in.

@@ -509,6 +509,8 @@ And then use the ``NEW`` DQL keyword :
$query = $em->createQuery('SELECT NEW CustomerDTO(c.name, e.email, a.city, SUM(o.value)) FROM Customer c JOIN c.email e JOIN c.address a JOIN c.orders o GROUP BY c');
$users = $query->getResult(); // array of CustomerDTO

Note that you cannot pass entities as constructor parameters for now.
Copy link
Contributor

Choose a reason for hiding this comment

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

What would be passed if I replace e.email with e? PK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIRC there was an error because an int was given, and I type-hinted the constructor with the object. Maybe the int is the entity id? I have no idea.

Copy link
Member

Choose a reason for hiding this comment

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

Only scalar expressions are supported..
Everything else causes a syntaxError/QueryException

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FabioBatSilva OK, I improved the message.

Copy link
Contributor

Choose a reason for hiding this comment

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

@FabioBatSilva I've tryed fill entity alias - got PK.

@mnapoli
Copy link
Contributor Author

mnapoli commented Jan 25, 2014

ping to anyone who can merge this is very trivial :)

FabioBatSilva added a commit that referenced this pull request Jan 25, 2014
Improved DQL's "new" operator documentation
@FabioBatSilva FabioBatSilva merged commit 9b7e949 into doctrine:master Jan 25, 2014
@mnapoli mnapoli deleted the patch-1 branch January 25, 2014 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants