2020-03-02 16:14:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ZM\DB;
|
|
|
|
|
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
use ZM\Exception\DbException;
|
|
|
|
|
|
2020-03-02 16:14:20 +08:00
|
|
|
class DeleteBody
|
|
|
|
|
{
|
|
|
|
|
use WhereBody;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var Table
|
|
|
|
|
*/
|
|
|
|
|
private $table;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* DeleteBody constructor.
|
|
|
|
|
* @param Table $table
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(Table $table) {
|
|
|
|
|
$this->table = $table;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
/**
|
|
|
|
|
* @return mixed
|
|
|
|
|
* @throws DbException
|
|
|
|
|
*/
|
2020-03-02 16:14:20 +08:00
|
|
|
public function save() {
|
|
|
|
|
list($sql, $param) = $this->getWhereSQL();
|
|
|
|
|
return DB::rawQuery("DELETE FROM " . $this->table->getTableName() . " WHERE " . $sql, $param);
|
|
|
|
|
}
|
2020-04-29 15:29:56 +08:00
|
|
|
}
|