Google Groups Home
Help | Sign in
Problem with Aggregate function via Doctrine_Query.
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
Mylith  
View profile
 More options 16 May, 15:50
From: Mylith <myl...@gmail.com>
Date: Fri, 16 May 2008 07:50:47 -0700 (PDT)
Local: Fri 16 May 2008 15:50
Subject: Problem with Aggregate function via Doctrine_Query.
Hello,

Please take a look, some code for example:

$query = Doctrine_Query::create()
->select('t.*, MIN(f.date) AS mdd')
->from('Twr t')
->leftJoin('t.ZmoPz zp, zp.FkPz fp, fp.Fk f')
->where('t.id = ?', 14843)
->groupby('t.id, t.code, t.name')
->orderby('t.nameASC')
->execute();

$query[0]->contains('mdd') - FALSE
$query[0]->ZmoPz[0]->contains('mdd') - FALSE
$query[0]->ZmoPz[0]->FkPz[0]->contains('mdd') - FALSE
$query[0]->ZmoPz[0]->FkPz[0]->Fk->contains('mdd') - FALSE

How can I find value :)? Im using profiler, raw query was tested on DB
and MIN(f.date) has value, after large var_dump of $query value is
stored in some object, but there is no way to get it. Maybe its some
kind of bug with access to value.

Thanks for advise,
Mylith


    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 16 May, 18:03
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Fri, 16 May 2008 12:03:22 -0500
Local: Fri 16 May 2008 18:03
Subject: Re: [doctrine-dev] Problem with Aggregate function via Doctrine_Query.

Do a print_r($query->toArray(true)); and you will see the path to the value.

- Jon

--
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.
Mylith  
View profile
 More options 19 May, 08:48
From: Mylith <myl...@gmail.com>
Date: Mon, 19 May 2008 00:48:32 -0700 (PDT)
Local: Mon 19 May 2008 08:48
Subject: Re: Problem with Aggregate function via Doctrine_Query.
Thanks for reply Jon,

Simple print_r($query->toArray(true) prints content only for "Twr"
table (no nesting, wired? since we have $deep = true), and there is no
column "mdd".

Greetings,
Mylith

On 16 Maj, 19:03, "Jonathan Wage" <jonw...@gmail.com> wrote:


    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 19 May, 14:37
From: "Jonathan Wage" <jonw...@gmail.com>
Date: Mon, 19 May 2008 08:37:21 -0500
Local: Mon 19 May 2008 14:37
Subject: Re: [doctrine-dev] Re: Problem with Aggregate function via Doctrine_Query.

I think it may be because you need to select the primary key for the table
you are doing the MIN() on.

- Jon

--
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.
Mylith  
View profile
 More options 20 May, 09:46
From: Mylith <myl...@gmail.com>
Date: Tue, 20 May 2008 01:46:02 -0700 (PDT)
Local: Tues 20 May 2008 09:46
Subject: Re: Problem with Aggregate function via Doctrine_Query.
In this case select with primary key helps, value is accessible from
Fk object, but (right there is but;) when we have a collection (remove
where with primary key of Twr table, or any other where) we have drama
with "mdd" value.
This is sample of first 5 records that should have mdd value (I know
values from raw query) and path to get them.

$query[0]->ZmoPz[0]->FkPz[0]->Fk->contains('mdd') - TRUE
$query[1]->ZmoPz[0]->FkPz[2]->Fk->contains('mdd') - TRUE
$query[2]->ZmoPz[1]->FkPz[0]->Fk->contains('mdd') - TRUE
$query[3]->ZmoPz[2]->FkPz[0]->Fk->contains('mdd') - TRUE
$query[4]->ZmoPz[0]->FkPz[0]->Fk->contains('mdd') - TRUE

As far I as I know, aggregate value should be in first record (only
$query index should change), Im I wrong? We need to do three
iterations to find value?

--
Mylith

On 19 Maj, 15:37, "Jonathan Wage" <jonw...@gmail.com> wrote:


    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