This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/Sql/Statements/SqlDeleteStatement.php

40 lines
701 B
PHP
Raw Normal View History

<?php
class SqlDeleteStatement extends SqlStatement
{
protected $table;
protected $criterion;
public function getTable()
{
return $this->table;
}
public function setTable($table)
{
$this->table = new SqlStringExpression($table);
return $this;
}
public function getCriterion()
{
return $this->criterion;
}
public function setCriterion($criterion)
{
$this->criterion = $this->attachExpression($criterion);
return $this;
}
public function getAsString()
{
$sql = 'DELETE FROM ' . $this->table->getAsString() . ' ';
if (!empty($this->criterion) and !empty($this->criterion->getAsString()))
$sql .= ' WHERE ' . $this->criterion->getAsString();
return $sql;
}
}