Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
select from more that one table
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
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
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
 
dziobacz  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 13:22
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Fri, 6 Nov 2009 05:22:30 -0800 (PST)
Local: Fri 6 Nov 2009 13:22
Subject: select from more that one table
When I have select from many tables, for second and other tables I
must write all theirs columns and make aliases for them - it isn't
comfortable, I can make table_name.* to take all columns only for
first table, for others I can't - for example:

public function pobierzDaneDoWygenerowaniaPromocji()
  {
        $q = Doctrine_Query::create()
          ->select('t.*, a.name_airline as name_airline, a.promotion as
promotion)
          ->from('Travel t')
          ->innerJoin('t.Airline a');

        return $q->execute();
  }

Is other way, because it isn't comfortable ?????


    Reply    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.
Daniel Santos Bathke  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 13:33
From: Daniel Santos Bathke <danielbat...@gmail.com>
Date: Fri, 6 Nov 2009 11:33:47 -0200
Local: Fri 6 Nov 2009 13:33
Subject: Re: [doctrine-user] select from more that one table

If you dont use the method ->select() to tell what to bring, it will
understand that you want all fields .. once you are trying to select
table1.*, table2.*, i think thats more confortable not using the method
->select();

example:

public function pobierzDaneDoWygenerowaniaPromocji()
 {
       $q = Doctrine_Query::create()
         ->from('Travel t')
         ->innerJoin('t.Airline a');

       return $q->execute();
 }

I wish that help

2009/11/6 dziobacz <aaabbbcccda...@gmail.com>


    Reply    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.
dziobacz  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 14:16
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Fri, 6 Nov 2009 06:16:53 -0800 (PST)
Local: Fri 6 Nov 2009 14:16
Subject: Re: select from more that one table
What if I have tables:

tableA:
id_tableA
id_tableB
id_tableC

tableB:
id_tableB

tableC:
id_tableC

And query:

public function someFunction()
  {
        $q = Doctrine_Query::create()
          ->from('TableA a')
          ->innerJoin('a.tableB b')
          ->innerJoin('a.tableC c');

        return $q->execute();
  }

How can I then show records ?

On 6 Lis, 14:33, Daniel Santos Bathke <danielbat...@gmail.com> wrote:


    Reply    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.
Daniel Santos Bathke  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 15:21
From: Daniel Santos Bathke <danielbat...@gmail.com>
Date: Fri, 6 Nov 2009 13:21:52 -0200
Local: Fri 6 Nov 2009 15:21
Subject: Re: [doctrine-user] Re: select from more that one table

if you use hydrate array then, the fields will be organized in indexes, if
you use scalar, the alias of the table will be the part of the name of the
field, example: a_id_tableA, a_id_tableB, b_id_tableB

2009/11/6 dziobacz <aaabbbcccda...@gmail.com>


    Reply    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.
dziobacz  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 17:03
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Fri, 6 Nov 2009 09:03:19 -0800 (PST)
Local: Fri 6 Nov 2009 17:03
Subject: Re: select from more that one table
I have error: Unknown method Travel::getColumnA, Unknown method
Travel::getColumnB, Unknown method Travel::getColumnC,  why ??

Here is my tables and code:

tableA:
  id_tableA
  id_tableB
  id_tableC
  columnA

tableB:
  id_tableB
  columnB

tableC:
  id_tableC
  columnC

public function someFunction()
  {
        $q = Doctrine_Query::create()
          ->from('TableA a')
          ->innerJoin('a.tableB b')
          ->innerJoin('a.tableC c');

        return $q->execute();
  }

$list = Doctrine::getTable('Travel')->someFunction();

foreach($list as $x):
      echo $x->getColumnA();
      echo $x->getColumnB();
      echo $x->getColumnC();
endforeach;

On 6 Lis, 16:21, Daniel Santos Bathke <danielbat...@gmail.com> wrote:


    Reply    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.
Daniel Santos Bathke  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 17:08
From: Daniel Santos Bathke <danielbat...@gmail.com>
Date: Fri, 6 Nov 2009 15:08:14 -0200
Local: Fri 6 Nov 2009 17:08
Subject: Re: [doctrine-user] Re: select from more that one table

Its because $x does not have a columnB .. $x is a record from TableA, you
have to get the child element .. every innerJoin table has a child element
..

Use, ->setHydrationMode(Doctrine::HYDRATE_ARRAY) in your dql, and then
print_r the result .. you will understand.

2009/11/6 dziobacz <aaabbbcccda...@gmail.com>


    Reply    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.
dziobacz  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 17:29
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Fri, 6 Nov 2009 09:29:05 -0800 (PST)
Local: Fri 6 Nov 2009 17:29
Subject: Re: select from more that one table
I understand but I don't know how can I in that case make loop. The
problem is that table TableA has 2 FK, please help with loop.

On 6 Lis, 18:08, Daniel Santos Bathke <danielbat...@gmail.com> wrote:


    Reply    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.
Daniel Santos Bathke  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 17:35
From: Daniel Santos Bathke <danielbat...@gmail.com>
Date: Fri, 6 Nov 2009 15:35:11 -0200
Local: Fri 6 Nov 2009 17:35
Subject: Re: [doctrine-user] Re: select from more that one table

You can do this if you use HYDRATE_ARRAY method:

            foreach($tableA as $indexa => $a)
            {
                    foreach($a['tableB'] as $indexb => $b)
                    {
                            echo $b['columnB'];
                    }
            }

2009/11/6 dziobacz <aaabbbcccda...@gmail.com>


    Reply    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.
dziobacz  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 18:45
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Fri, 6 Nov 2009 10:45:07 -0800 (PST)
Local: Fri 6 Nov 2009 18:45
Subject: Re: select from more that one table
This is so difficult - I have error: Uninitialized string offset: 0

On 6 Lis, 18:35, Daniel Santos Bathke <danielbat...@gmail.com> wrote:


    Reply    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.
Daniel Santos Bathke  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 18:56
From: Daniel Santos Bathke <danielbat...@gmail.com>
Date: Fri, 6 Nov 2009 16:56:07 -0200
Local: Fri 6 Nov 2009 18:56
Subject: Re: [doctrine-user] Re: select from more that one table

Be sure you are using HYDRATE_ARRAY method.
Be sure your array/index is filled with someting .. (if(cont(array[])).

2009/11/6 dziobacz <aaabbbcccda...@gmail.com>


    Reply    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.
Routy  
View profile   Translate to Translated (View Original)
 More options 6 Nov, 19:57
From: Routy <nickro...@gmail.com>
Date: Fri, 6 Nov 2009 11:57:29 -0800 (PST)
Local: Fri 6 Nov 2009 19:57
Subject: Re: select from more that one table
Construct your query as follows:

$results = Doctrine_Query::create()
          ->from('TableA a')
          ->innerJoin('a.tableB')
          ->innerJoin('a.tableC');
          ->execute(array(),Doctrine::HYDRATE_ARRAY);

Your results will be structured as an array rather than in an object -
so then just loop through the result set.

[0][tableAfield1]
   [tableAfield2]
   [tableAfield3]
   [tableB][tableBfield1]
           [tableBfield2]
           [tableBfield3]
   [tableC][tableCfield1]
           [tableCfield2]
           [tableCfield3]

foreach($results as $r){

    echo $r['tableAfield1'];
    echo $r['tableB']['tableBfield1'];

}

Hope that sets you straight ;)

http://blog.routydesign.com


    Reply    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.
dziobacz  
View profile   Translate to Translated (View Original)
 More options 7 Nov, 08:38
From: dziobacz <aaabbbcccda...@gmail.com>
Date: Sat, 7 Nov 2009 00:38:16 -0800 (PST)
Local: Sat 7 Nov 2009 08:38
Subject: Re: select from more that one table
ROUTY this is it what I needed - now I understand - THX SO MUCH !! YOU
ARE GREAT !!
As I find also on this site: http://www.symfony-project.org/doctrine/1_2/en/06-Working-With-Data
$q->execute(array(), Doctrine::HYDRATE_ARRAY) == $q->fetchArray()
so I use fetchArray() but without Your example I didn't know what to
do - THX AND THX AGAIN :)

Of cours thx also for Daniel :)

THX PEOPLE !!!

On 6 Lis, 20:57, Routy <nickro...@gmail.com> wrote:


    Reply    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
©2009 Google