2020-03-02 16:14:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
declare(strict_types=1);
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
namespace ZM\DB;
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
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.
|
|
|
|
|
*/
|
2022-03-15 18:05:33 +08:00
|
|
|
public function __construct(Table $table)
|
|
|
|
|
{
|
2020-03-02 16:14:20 +08:00
|
|
|
$this->table = $table;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-29 15:29:56 +08:00
|
|
|
/**
|
|
|
|
|
* @throws DbException
|
2022-03-15 18:05:33 +08:00
|
|
|
* @return mixed
|
2020-04-29 15:29:56 +08:00
|
|
|
*/
|
2022-03-15 18:05:33 +08:00
|
|
|
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
|
|
|
}
|
2020-04-29 15:29:56 +08:00
|
|
|
}
|