Welcome, Guest
Username: Password: Remember me

TOPIC: [FAQ] What is the Cook GroupBy statement

[FAQ] What is the Cook GroupBy statement 12 Feb 2013 14:24 #6710

  • rnevins
  • rnevins's Avatar
  • Offline
  • Junior Member
  • Posts: 24
  • Thank you received: 6
  • Karma: 1
I think there is a bug in the groupby code as follows:

Code generated:

//ORDER
foreach($this->getState('query.groupby', array()) as $groupby)
$query->order($groupby);

//ORDER
foreach($this->getState('query.order', array()) as $order)
$query->order($order);

Code should be (I think):

//GROUP
foreach($this->getState('query.groupby', array()) as $groupby)
$query->group($groupby);

//ORDER
foreach($this->getState('query.order', array()) as $order)
$query->order($order);
Last Edit: 12 Feb 2013 15:05 by rnevins.
The administrator has disabled public write access.

[FAQ] What is the Cook GroupBy statement 12 Feb 2013 15:41 #6711

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi there @rnevins and thanks for posting this...

Can I just ask whether you experienced any malfunction, odd behaviour or anything that led you to find this or is it just a case of it looking wrong?

Clearly, it looks wrong and your suggestion looks to be correct however, I'm just interested to see if there are any weird symptoms as I've never noticed it before!

Also, please could you share your configuration (the builder config) as well as what version of Cook you are using!

Thanks

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

[FAQ] What is the Cook GroupBy statement 12 Feb 2013 21:53 #6715

  • rnevins
  • rnevins's Avatar
  • Offline
  • Junior Member
  • Posts: 24
  • Thank you received: 6
  • Karma: 1
Hi,

I am using the V2.0 Beta version of Cook. I'm not sure I understand what you mean by the builder config. I am new to using Cook.

I was customizing the generated code by adding a $this->setState('query.groupby'...) in the prepareQuery function. I was using debug to follow the execution of the code and noticed that the group method wasn't executed and then found the statement which looked like it was a cut/paste from the section that was doing the $query->order but "order" wasn't changed to "group". When I made the correction, it executed as expected.

Hope that helps explain.

Thanks,

Rick
The administrator has disabled public write access.

[FAQ] What is the Cook GroupBy statement 13 Feb 2013 08:38 #6725

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Rick,

Thanks for the explanation - karma++ and welcome BTW!
rnevins wrote:
...I'm not sure I understand what you mean by the builder config. I am new to using Cook...
I meant the Config tab in the cook builder where you specify the JS framework, Forms handling, DB automations and timeout settings etc.

Thanks again,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

[FAQ] What is the Cook GroupBy statement 13 Feb 2013 10:54 #6727

  • rnevins
  • rnevins's Avatar
  • Offline
  • Junior Member
  • Posts: 24
  • Thank you received: 6
  • Karma: 1
Thanks. Below are my config settings:

JS Framework - MooTools
Embed - No
Framework Form style - Condensed
Features - Reduced
TODO - No

DB automatisms - Model
Timeout loading - 20 seconds

Rick
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

[FAQ] What is the Cook GroupBy statement 13 Feb 2013 11:10 #6728

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Thanks Rick,

just posting this to @admin to take a look when he gets chance and thanks again for your sharp eyes!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

[FAQ] What is the Cook GroupBy statement 13 Feb 2013 15:08 #6731

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 984
  • Karma: 140
This is not a bug. It is normal.

The concept of grouping in cook is different than grouping in SQL.

When you group a list, it instance a second ordering but prioritary.

Groupby1
Groupby2
Ordering1
Ordering2

So that means even if you change the order of your table, the groups are still instancied properly in order.

SQL GROUP BY statement is agregating the results for sums, or else. Nothing to do with a list group.

That's it.
Thank you for asking.
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy, rnevins
Time to create page: 0.110 seconds

Get Started