From 22e24b17b4888e62fc7ee59e3516f1d063d342b1 Mon Sep 17 00:00:00 2001 From: Simon Holywell Date: Mon, 12 Nov 2012 11:20:46 +0000 Subject: Issue #16 Aggregate function support --- README.markdown | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'README.markdown') diff --git a/README.markdown b/README.markdown index a2b2ac7..f303457 100644 --- a/README.markdown +++ b/README.markdown @@ -34,6 +34,7 @@ Changelog * Allow an associative array to be passed to `configure` method [[jordanlev](http://github.com/jordanlev)] * Patch to allow empty Paris models to be saved ([[j4mie/paris](http://github.com/j4mie/paris)]) issue #58 * Add `select_many` and `select_many_expr` - closing issues #49 and #69 +* Add support for `MIN`, `AVG`, `MAX` and `SUM` - closes issue #16 #### 1.1.1 - release 2011-01-30 @@ -343,6 +344,16 @@ The `join` methods also take an optional third parameter, which is an `alias` fo ->join('person', array('p1.parent', '=', 'p2.id'), 'p2') ->find_many(); +#### Aggregate functions #### + +There is support for `MIN`, `AVG`, `MAX` and `SUM` in addition to `COUNT` (documented earlier). + +To return a minimum value of column, call the `min()` method. + + $min = ORM::for_table('person')->min('height'); + +The other functions (`AVG`, `MAX` and `SUM`) work in exactly the same manner. Supply a column name to perform the aggregate function on and it will return an integer. + #### Raw queries #### If you need to perform more complex queries, you can completely specify the query to execute by using the `raw_query` method. This method takes a string and optionally an array of parameters. The string can contain placeholders, either in question mark or named placeholder syntax, which will be used to bind the parameters to the query. -- cgit v1.2.3