Skip to content

Commit

Permalink
Added limit offset and where resetters
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-deluna committed Jun 15, 2016
1 parent 398a9d0 commit 46d9e3a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Query/Sql/SelectBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,36 @@ protected function stringArgumentToArray($argument)
return array($argument);
}

/**
* Will reset the current selects where conditions
*
* @return self
*/
public function resetWheres()
{
$this->wheres = array(); return $this;
}

/**
* Will reset the current selects limit
*
* @return self
*/
public function resetLimit()
{
$this->limit = null; return $this;
}

/**
* Will reset the current selects offset
*
* @return self
*/
public function resetOffset()
{
$this->offset = null; return $this;
}

/**
* Create a where statement
*
Expand Down
24 changes: 24 additions & 0 deletions tests/Query/Sql/BaseSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public function testWhere()
));
}

/**
* BaseSql::whereReset
*/
public function testWhereReset()
{
$this->assertAttributes($this->createQuery()->where('id', 42)->resetWheres(), array());
}

/**
* BaseSql::orWhere
*/
Expand Down Expand Up @@ -211,6 +219,14 @@ public function testLimit()
$this->assertAttributes($this->createQuery()->limit(10)->limit(null));
}

/**
* BaseSql::limitReset
*/
public function testLimitReset()
{
$this->assertAttributes($this->createQuery()->limit(10)->resetLimit(), array());
}

/**
* BaseSql::offset
*/
Expand All @@ -223,6 +239,14 @@ public function testOffset()
$this->assertAttributes($this->createQuery()->limit(2, 5)->offset(3), array('limit' => 5, 'offset' => 3));
}

/**
* BaseSql::offsetReset
*/
public function testOffsetReset()
{
$this->assertAttributes($this->createQuery()->offset(10)->resetOffset(), array());
}

/**
* BaseSql::page
*/
Expand Down

0 comments on commit 46d9e3a

Please sign in to comment.