zhamao-framework/src/ZM/DB/DeleteBody.php

40 lines
706 B
PHP
Raw Normal View History

2020-03-02 16:14:20 +08:00
<?php
declare(strict_types=1);
2020-03-02 16:14:20 +08:00
namespace ZM\DB;
use ZM\Exception\DbException;
2021-07-09 01:38:30 +08:00
/**
* Class DeleteBody
* @deprecated This will delete in 2.6 or future version, use \ZM\MySQL\MySQLManager::getConnection() instead
*/
2020-03-02 16:14:20 +08:00
class DeleteBody
{
use WhereBody;
/**
* @var Table
*/
private $table;
/**
* DeleteBody constructor.
*/
public function __construct(Table $table)
{
2020-03-02 16:14:20 +08:00
$this->table = $table;
}
/**
* @throws DbException
* @return mixed
*/
public function save()
{
[$sql, $param] = $this->getWhereSQL();
return DB::rawQuery('DELETE FROM ' . $this->table->getTableName() . ' WHERE ' . $sql, $param);
2020-03-02 16:14:20 +08:00
}
}