Google Groups Home
Help | Sign in
DQL join correlated subqueries.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Brice Figureau  
View profile
 More options May 14, 7:37 am
From: Brice Figureau <brice+doctr...@daysofwonder.com>
Date: Wed, 14 May 2008 13:37:20 +0200
Local: Wed, May 14 2008 7:37 am
Subject: DQL join correlated subqueries.
Hi,

I'm trying to mimic in DQL a SQL query that contains a correlated
subquery in a join, ala:

SELECT ...
FROM
 Table as t
LEFT JOIN
 OtherTable as o ON <o condition>
LEFT JOIN
  (SELECT count(*) FROM AnyOtherTable) as r ON <r condition>
WHERE
  <where condition>

It doesn't seem to work.
So first, is this something possible?
And if yes, what would be the DQL syntax for it?

Thanks,
--
Brice Figureau <brice+doctr...@daysofwonder.com>


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile
 More options May 14, 10:43 am
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Wed, 14 May 2008 09:43:19 -0500
Local: Wed, May 14 2008 10:43 am
Subject: Re: [doctrine-user] DQL join correlated subqueries.

Hmm. I don't understand. How would that work anyways? You are doing a left
join subquery where it is a count?

You should be able to do a subquery in a join, have you tried it?

- Jon

On Wed, May 14, 2008 at 6:37 AM, Brice Figureau <

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brice Figureau  
View profile
 More options May 14, 5:24 pm
From: "Brice Figureau" <brice+doctr...@daysofwonder.com>
Date: Wed, 14 May 2008 23:24:43 +0200 (CEST)
Local: Wed, May 14 2008 5:24 pm
Subject: Re: [doctrine-user] Re: DQL join correlated subqueries.
Hi,

Oops, forgot a part in the query...

SELECT ...
FROM
 Table as t
LEFT JOIN
  OtherTable as o ON o.id = t.id
LEFT JOIN
  (SELECT a.id, count(*) as count FROM AnyOtherTable as a GROUP BY a.id)
as r ON r.id=t.id
WHERE
  <where condition>

Is this something doctrine/dql support?
And if yes, what would be the DQL syntax?

Thanks,
Brice

--
Brice Figureau
Days of Wonder

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile
 More options May 14, 6:14 pm
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Wed, 14 May 2008 17:14:27 -0500
Local: Wed, May 14 2008 6:14 pm
Subject: Re: [doctrine-user] Re: DQL join correlated subqueries.

I don't know off the top of my head what the syntax would be. But yes, DQL
does support sub-queries.

- Jon

On Wed, May 14, 2008 at 4:24 PM, Brice Figureau <

--
Jonathan Wage
http://www.jwage.com
http://www.centresource.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Brice Figureau  
View profile
 More options May 16, 8:29 am
From: Brice Figureau <brice+doctr...@daysofwonder.com>
Date: Fri, 16 May 2008 14:29:19 +0200
Local: Fri, May 16 2008 8:29 am
Subject: Re: [doctrine-user] Re: DQL join correlated subqueries.
Hi Jon,

Thanks for your answer.

I dug a little bit in the Doctrine_Query code and it seems that the kind
of from subquery I'm trying to achieve is impossible with Doctrine.

I think this is just because Doctrine would have to define dynamically a
new kind of Doctrine_Record and a new relation to the joined tables.

I fail to see how Doctrine could do that, but I might be wrong.
The problem is that I can't do that either in RawSQL, because I can't
select on such dynamic object.
I fear I'll have to HYDRATE_NONE/HYDRATE_ARRAY or perform the request
out of the join (ie issue one request per returned Record of the master
query).

Thanks,
Brice


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google