This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » doctrine execute only returns one row
doctrine execute only returns one row [message #103140] Tue, 27 July 2010 17:46 Go to next message
weiserc  is currently offline weiserc
Messages: 23
Registered: December 2007
Junior Member
Hi,

I have a query over several tables that should return a count value and one groupby column

I have the query set up and it works. I have tested the sql directly on the sql server and get the results I want. When my applications does the query though I only get one row of the result

Here my query and source code:

    $q = Doctrine_Query::create()
      ->select('count(mp.idMember) as members, mp.idReason as reason')
      ->from('Member m, MemberPeriod mp, Org o')
      ->where('m.id=mp.id AND m.idOrg=o.idOrg AND o.tcode
        LIKE \''.substr($this->getCode(), 0, 5) . '%\' AND mp.end >= \''.$quart->getStart().'\'
        AND mp.end <= \''.$quart->getEnd().'\'')
      ->groupBy('mp.idReason');
    $zu = $q->execute(array(), Doctrine_Core::HYDRATE_ARRAY);

which results in
SELECT COUNT([s2].[id]) AS [s2__0], [s2].[idreason] AS [s2__1]
FROM [Member] [s], [MemberPeriod] [s2], [Org] [s3] 
WHERE ([s].[id] = [s2].[id] AND
[s].[idorg] = [s3].[idorg] AND 
[s3].[tcode] LIKE '40111%' AND [s2].[end] >= '2010-01-01' AND
[s2].[end] <= '2010-03-31') 
GROUP BY [s2].[idreason]


The print_r on $zu gives me

Array ( [0] => Array ( [members] => 3 [reason] => 1 ) ) 


The result direct from the server is

members reason
1	9
4	26
1	35
3	1
2	31


I'm only getting the result from row 4.

can anyone help me here?


Would you like to be a candidate in your own US presidential election? Check out http://www.yourelection.net/us_election_game.php (powered by symfony)
Re: doctrine execute only returns one row [message #103168 is a reply to message #103140 ] Wed, 28 July 2010 11:21 Go to previous message
tkoomzaaskz  is currently offline tkoomzaaskz
Messages: 101
Registered: February 2008
Location: Poland
Senior Member
Maybe there is something wrong with joining tables? Have you tried leftJoin? Possibly, you've got a bug somewhere there. In such cases I recommend to remove parts of a query one by one to find out which step has a hidden bug.

It can't be any Doctrine error.


symfony-world blog
Previous Topic:[solved] admin generator - disable creating new object
Next Topic:overriding delete method in a Many-to-Many relation
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software