Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

group_by_expr? #24

Closed
philoye opened this issue Feb 19, 2011 · 2 comments
Closed

group_by_expr? #24

philoye opened this issue Feb 19, 2011 · 2 comments
Assignees
Milestone

Comments

@philoye
Copy link

philoye commented Feb 19, 2011

I found a need for a group_by_expr because backticking of the column names was getting in the way. I wanted to do something like:

   ->group_by_expr("FROM_UNIXTIME(`time`, '%Y-%m')")

A super simple patch. Not sure whether it would be of interest to you:

    /**
    * Add an unquoted expression to the list of columns to GROUP BY 
    */
    public function group_by_expr($expr) {
          $this->_group_by[] = $expr;
          return $this;
    }
@philoye
Copy link
Author

philoye commented Feb 22, 2011

Well, I'm an idiot. It turns out I don't actually need the above method because I can just do:

   ->select_expr("FROM_UNIXTIME(`time`, '%Y-%m')", 'month')
   ->group_by('month')

Maybe the above patch could be useful to someone, but that person is not me at the moment.

Cheers,
p.

@treffynnon
Copy link
Collaborator

The alias route is the best way to proceed with this, but I think it doesn't hurt to also support this with the patch as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants