CodeIgniter Forums
Resetting active record 'group_by' - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Resetting active record 'group_by' (/showthread.php?tid=13610)



Resetting active record 'group_by' - El Forum - 11-29-2008

[eluser]Daniel H[/eluser]
For a particular reason, I use a common field filtering function to run my GET and COUNT statements. To cut a long story short, one of these common filtering statements contains a GROUP BY line, which obviously doesn't work when a COUNT is performed.

So is there a way to reset the GROUP BY to nothing after it has been set?

Thanks,

Dan.


Resetting active record 'group_by' - El Forum - 11-29-2008

[eluser]Daniel H[/eluser]
Ignore this. I just use this:

Code:
$this->db->ar_groupby = array();



Resetting active record 'group_by' - El Forum - 11-29-2008

[eluser]Jon L[/eluser]
doesn't starting a new query reset it already?


Resetting active record 'group_by' - El Forum - 11-30-2008

[eluser]Daniel H[/eluser]
It would do yes, but I'm trying to using the same filters for my GET as my COUNT in the spirit of DRY.


Resetting active record 'group_by' - El Forum - 11-30-2008

[eluser]Jon L[/eluser]
in that case, using start_cache, stop_cache, flush_cache, etc, may suit your needs.

could start_cache, build query, stop_cache, count, change params, execute, flush_cache