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