Skip to content

Aggregate function support #16

@j4mie

Description

@j4mie

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…

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions