for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Puzzle\QueryBuilder\Queries;
use Puzzle\QueryBuilder\Query;
use Puzzle\QueryBuilder\Traits\EscaperAware;
use Puzzle\QueryBuilder\Snippet;
use Puzzle\QueryBuilder\Queries\Snippets\Builders;
class Delete implements Query
{
use
EscaperAware,
Builders\Join,
Builders\Where,
Builders\OrderBy,
Builders\Limit;
private
$from;
$from
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
class A { var $property; }
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.
/**
* @param TableName|string $table
*/
public function __construct($table = null, ?string $alias = null)
if(!empty($table))
$this->from($table, $alias);
}
$this->where = new Snippets\Where();
$this->orderBy = new Snippets\OrderBy();
public function toString(): string
$queryParts = array(
'DELETE',
$this->buildFrom(),
$this->buildJoin(),
$this->buildWhere($this->escaper),
$this->buildOrderBy(),
$this->buildLimit(),
);
return implode(' ', array_filter($queryParts));
public function from($table, ?string $alias = null): self
$this->from = new Snippets\From($table, $alias);
return $this;
private function buildFrom(): string
if(!$this->from instanceof Snippet)
throw new \LogicException('No column for FROM clause');
return $this->from->toString();
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.