public static deleteMessageById ( $id ) : boolean | ||
$id | ||
Результат | boolean |
public static function deleteMessageById($id)
{
$inTransaction = DB::getInstance()->inTransaction();
if (!$inTransaction) {
DB::getInstance()->beginTransaction();
}
$statement = DB::getInstance()->prepare("DELETE FROM `message` WHERE id=:id");
$statement->bindValue(':id', $id, DB::PARAM_INT);
$result = $statement->execute();
if (!$inTransaction) {
DB::getInstance()->commit();
}
return $result;
}
/** * 删除 * @JSON */ public function delete() { $result = array('error' => 1, 'message' => 'Request failed'); if ($_POST['message_id'] != null) { MessageModel::deleteMessageById(intval(trim($_POST['message_id']))); $result = array('error' => 0, 'message' => '删除成功'); } return $result; }