for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Wandu\Database\Query\Expression;
use Wandu\Database\Contracts\ExpressionInterface;
class LimitExpression implements ExpressionInterface
{
/** @var int */
protected $take;
protected $offset;
/**
* @param int $take
* @return static
*/
public function take($take = null)
$this->take = $take;
return $this;
}
* @param int $offset
public function offset($offset = null)
$this->offset = $offset;
public function limit($offset, $take)
* {@inheritdoc}
public function toSql()
if (!isset($this->take) && !isset($this->offset)) {
return '';
$sqlParts = [];
if (isset($this->take)) {
$sqlParts[] = "LIMIT ?";
if (isset($this->offset)) {
$sqlParts[] = "OFFSET ?";
return implode(" ", $sqlParts);
public function getBindings()
$bindings = [];
$bindings[] = $this->take;
$bindings[] = $this->offset;
return $bindings;