/** * @brief delete the notification with the given id * @param $uid user id * @param $id notification id * @return number of affected rows */ public static function deleteById($uid = null, $id) { if (is_null($uid)) { if (OCP\User::isLoggedIn()) { $uid = OCP\User::getUser(); } else { return 0; } } if (!isset(self::$deleteParamsByIdStmt)) { self::$deleteParamsByIdStmt = OCP\DB::prepare("DELETE FROM *PREFIX*notification_params WHERE nid IN (SELECT id FROM *PREFIX*notifications WHERE id = ? AND uid = ?)"); } if (!isset(self::$deleteByIdStmt)) { self::$deleteByIdStmt = OCP\DB::prepare("DELETE FROM *PREFIX*notifications WHERE id = ? AND uid = ?"); } self::$deleteParamsByIdStmt->execute(array($id, $uid)); self::$deleteByIdStmt->execute(array($id, $uid)); return self::$deleteByIdStmt->numRows(); }