diff options
author | Indieteq <admin@indieteq.com> | 2013-09-09 20:43:43 +0200 |
---|---|---|
committer | Indieteq <admin@indieteq.com> | 2013-09-09 20:43:43 +0200 |
commit | 8fb5251aa1cbaf872e953c2125e0316220196c33 (patch) | |
tree | cd0c199fdbd524e44145a384a8dc47c628963ff3 | |
parent | b166f0ad7581d43f39c0f41abd4fe727cda77be8 (diff) | |
download | php-mysql-pdo-database-class-8fb5251aa1cbaf872e953c2125e0316220196c33.zip php-mysql-pdo-database-class-8fb5251aa1cbaf872e953c2125e0316220196c33.tar.gz php-mysql-pdo-database-class-8fb5251aa1cbaf872e953c2125e0316220196c33.tar.bz2 |
Added aggregate functions
Added Aggregate methods such as : min, max, avg, sum etc
-rw-r--r-- | easyCRUD/easyCRUD.class.php | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/easyCRUD/easyCRUD.class.php b/easyCRUD/easyCRUD.class.php index d6e6bff..5e21bbe 100644 --- a/easyCRUD/easyCRUD.class.php +++ b/easyCRUD/easyCRUD.class.php @@ -99,5 +99,31 @@ class Crud { public function all(){ return $this->db->query("SELECT * FROM " . $this->table); } + + public function min($field) { + if($field) + return $this->db->single("SELECT min(" . $field . ")" . " FROM " . $this->table); + } + + public function max($field) { + if($field) + return $this->db->single("SELECT max(" . $field . ")" . " FROM " . $this->table); + } + + public function avg($field) { + if($field) + return $this->db->single("SELECT avg(" . $field . ")" . " FROM " . $this->table); + } + + public function sum($field) { + if($field) + return $this->db->single("SELECT sum(" . $field . ")" . " FROM " . $this->table); + } + + public function count($field) { + if($field) + return $this->db->single("SELECT count(" . $field . ")" . " FROM " . $this->table); + } + } -?>
\ No newline at end of file +?> |