Welcome Guest, Not a member yet? Register   Sign In
Active Record - Group by DATE_FORMAT()
#4

[eluser]Karinsson[/eluser]
I know this is an old thread but i ran into the exact same problem, found this page on the first google search, and the fix above did not solve it.

It worked for me by simply parsing the group_by parameter as an array instead of a string as the comma in the DATE_FORMAT function will cause the string to be exploded.

Parsing a SQL function as a string returns an error (if the string has one or more commas)
Code:
$this->db->group_by("DATE_FORMAT(date, '%x-%v')";

// Generates GROUP BY DATE_FORMAT(date, `'%x-%v')`

Parsing a SQL function in an array does not Smile
Code:
$this->db->group_by(array("DATE_FORMAT(date, '%x-%v')");

// Generates GROUP BY DATE_FORMAT(date, '%x-%v')


Messages In This Thread
Active Record - Group by DATE_FORMAT() - by El Forum - 02-25-2010, 07:09 AM
Active Record - Group by DATE_FORMAT() - by El Forum - 02-25-2010, 08:59 AM
Active Record - Group by DATE_FORMAT() - by El Forum - 02-25-2010, 09:02 AM
Active Record - Group by DATE_FORMAT() - by El Forum - 05-22-2012, 09:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB