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

Aggregate function support #16

Closed
j4mie opened this issue Jan 28, 2011 · 2 comments
Closed

Aggregate function support #16

j4mie opened this issue Jan 28, 2011 · 2 comments
Assignees
Milestone

Comments

@j4mie
Copy link
Owner

j4mie commented Jan 28, 2011

From Sérgio Diniz (by email):

I found one thing that I really miss, is the max function, instead of using a raw query it could be already in your ORM… so I implemented it quickly:

/**
* Tell the ORM that you wish to execute a MAX query.
* Will return the max value of the choosen column.
*/
public function max($column)  {
   $this->select_expr('MAX('.$column.')', 'maxvalue');
   $result = $this->find_one();
   return ($result !== false && isset($result->maxvalue)) ? (int) $result->maxvalue : 0;
}

I only tested it in MySQL…

@j4mie
Copy link
Owner Author

j4mie commented Jan 28, 2011

It looks like MAX, MIN, AVG and SUM are ANSI standard SQL so should be fairly portable. More research needed.

@lawrencegs
Copy link

So far we only have count. Any chance we can have more of these fairly standard aggregation function?

@ghost ghost assigned treffynnon Nov 9, 2012
treffynnon added a commit that referenced this issue Nov 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants