Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion LEFT JOIN / joined results not handled
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
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Jonathan Wage  
View profile   Translate to Translated (View Original)
 More options 8 July, 19:20
From: Jonathan Wage <jonw...@gmail.com>
Date: Wed, 8 Jul 2009 13:20:00 -0500
Subject: Re: [doctrine-user] LEFT JOIN / joined results not handled

I think it is because you are not selecting enough data from the cc alias.
Try just changing it to a wide open select by removing the select() line.

- Jon

On Wed, Jul 8, 2009 at 1:18 PM, James Tucker <tenlet...@gmail.com> wrote:

> Hello there,

> i encountered a problem, when using a left join command in a query.
> Basically, what happened is that my joined results were not appearing
> in the final results of the query. After carefully testing the
> validity of the actual query (by testing the query to mysql directly)
> i realized that the problem can not originate from mysql as such.

> A few details:

> Model A:
> Consists of an (primary key) 'id' of type string, length 16
> and a few other fields, most importantly for this example a field
> 'code' (string/10)

> Model B:
> Has a field 'mandantPath' that is related to model A (field id)
> through a hasOne() relation.

> #code
> $this->hasOne('mandant_db_node as mandant', array
> ('local'=>'mandantPath','foreign'=>'id'));

> #here is my query

>        $l=Doctrine_Query::create()
>                         ->select('*,p.code')
>                         ->from('contact_db_customer cc')
>                         ->leftJoin('cc.mandant p')
>                         ->where($w)
>                         ->offset($request['startindex']+0)
>                         ->limit($request['rows']+0)
>                         ->orderBy($order)
>                         ->execute(array());

> Now, if i call this the way i do (above), i get the basic results
> (fields), but not the joined ones. If i get the SQL query generated by
> Doctrine, and use it directly, it works just fine and it returns the
> 'code' field as it should.

> However, when i add type Doctrine::HYDRATE_ARRAY to the execute
> command, i get the correct results, but of course encapsuled.. so that
> i have to loop/parse through the result and set the values according
> to my demands.

> Pretty frustrating - while i am certain that the problem is very basic
> and i just lack the knowledge of a proper solution. Hopefully someone
> in here knows what i am dealing with - specifically, what it is that i
> am doing wrong.

> Kind regards, James

--
Jonathan H. Wage (+1 415 992 5468)
Open Source Software Developer & Evangelist
sensiolabs.com | jwage.com | doctrine-project.org | symfony-project.org

You can contact Jonathan about Doctrine, Symfony and Open-Source or for
training, consulting, application development, or business related questions
at jonathan.w...@sensio.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.

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