Skip to content

Commit

Permalink
Release version 1.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
FaaPz committed Dec 2, 2015
1 parent 18a7948 commit 100fec2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### Changelog

##### v1.9.1
+ Updated `SelectStatement` class with:
- Fixed all aggregates

##### v1.9.0
+ Added `whereMany` method
+ Updated `limit()` method
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "slim/pdo",
"description": "PDO database library for Slim Framework",
"version": "1.9.0",
"version": "1.9.1",
"type": "library",
"keywords": ["pdo", "database", "slim", "framework"],
"homepage": "https://github.com/FaaPz/Slim-PDO",
Expand Down
19 changes: 19 additions & 0 deletions src/PDO/Statement/SelectStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class SelectStatement extends StatementContainer
*/
private $distinct = false;

/**
* @var bool
*/
private $aggregate = false;

/**
* @var JoinClause
*/
Expand Down Expand Up @@ -85,6 +90,8 @@ public function distinct()
*/
public function count($column = '*', $as = null, $distinct = false)
{
$this->aggregate = true;

$this->columns[] = $this->setDistinct($distinct).' '.$column.' )'.$this->setAs($as);

return $this;
Expand All @@ -111,6 +118,8 @@ public function distinctCount($column = '*', $as = null)
*/
public function max($column, $as = null)
{
$this->aggregate = true;

$this->columns[] = 'MAX( '.$column.' )'.$this->setAs($as);

return $this;
Expand All @@ -124,6 +133,8 @@ public function max($column, $as = null)
*/
public function min($column, $as = null)
{
$this->aggregate = true;

$this->columns[] = 'MIN( '.$column.' )'.$this->setAs($as);

return $this;
Expand All @@ -137,6 +148,8 @@ public function min($column, $as = null)
*/
public function avg($column, $as = null)
{
$this->aggregate = true;

$this->columns[] = 'AVG( '.$column.' )'.$this->setAs($as);

return $this;
Expand All @@ -150,6 +163,8 @@ public function avg($column, $as = null)
*/
public function sum($column, $as = null)
{
$this->aggregate = true;

$this->columns[] = 'SUM( '.$column.' )'.$this->setAs($as);

return $this;
Expand Down Expand Up @@ -412,6 +427,10 @@ private function getSelect()
*/
private function getColumns()
{
if ($this->aggregate) {
array_splice($this->columns, 0, -1);
}

return implode(' , ', $this->columns);
}

Expand Down

0 comments on commit 100fec2

Please sign in to comment.