本文整理汇总了PHP中Rating::Delete方法的典型用法代码示例。如果您正苦于以下问题:PHP Rating::Delete方法的具体用法?PHP Rating::Delete怎么用?PHP Rating::Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rating
的用法示例。
在下文中一共展示了Rating::Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
/**
* Delete a record
* @param integer $id ID of record to be deleted
* @return void Record is deleted from database
*/
static function Delete($id)
{
App::LoadClass('Privacy');
App::LoadClass('Avatar');
App::LoadClass('Video');
App::LoadClass('Subscription');
App::LoadClass('Rating');
App::LoadClass('Flag');
App::LoadClass('Favorite');
App::LoadClass('Comment');
App::LoadClass('Post');
App::LoadClass('Message');
$db = Database::GetInstance();
$user = new self($id);
Plugin::Trigger('user.delete');
// Delete Avatar
if (!empty($user->avatar)) {
Avatar::Delete($user->avatar);
}
// Delete Privacy Record
$privacy_id = Privacy::Exist(array('user_id' => $id));
Privacy::Delete($privacy_id);
// Delete Comments
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Comment::Delete($row->comment_id);
}
// Delete Ratings
$query = "SELECT rating_id FROM " . DB_PREFIX . "ratings WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Rating::Delete($row->rating_id);
}
// Delete Favorites
$query = "SELECT fav_id FROM " . DB_PREFIX . "favorites WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Favorite::Delete($row->fav_id);
}
// Delete Flags
$query = "SELECT flag_id FROM " . DB_PREFIX . "flags WHERE id = {$id} AND type = 'user'";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Flag::Delete($row->flag_id);
}
// Delete Subscriptions
$query = "SELECT sub_id FROM " . DB_PREFIX . "subscriptions WHERE user_id = {$id} OR member = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Subscription::Delete($row->sub_id);
}
// Delete Posts
$query = "SELECT post_id FROM " . DB_PREFIX . "posts WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Post::Delete($row->post_id);
}
// Delete Messages
$query = "SELECT message_id FROM " . DB_PREFIX . "messages WHERE user_id = {$id} OR recipient = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Message::Delete($row->message_id);
}
// Delete Videos
$query = "SELECT video_id FROM " . DB_PREFIX . "videos WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Video::Delete($row->video_id);
}
// Delete Privacy
$query = "SELECT privacy_id FROM " . DB_PREFIX . "privacy WHERE user_id = {$id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Privacy::Delete($row->privacy_id);
}
// Delete User
$query = "DELETE FROM " . DB_PREFIX . self::$table . " WHERE " . self::$id_name . " = {$id}";
$db->Query($query);
}
示例2: Delete
/**
* Delete a video
* @param integer $video_id ID of video to be deleted
* @return void Video is deleted from database and all related files and records are also deleted
*/
static function Delete($video_id)
{
App::LoadClass('Rating');
App::LoadClass('Flag');
App::LoadClass('Favorite');
App::LoadClass('Comment');
$db = Database::GetInstance();
$video = new self($video_id);
Plugin::Trigger('video.delete');
// Delete files
try {
Filesystem::Open();
Filesystem::Delete(UPLOAD_PATH . '/flv/' . $video->filename . '.flv');
Filesystem::Delete(UPLOAD_PATH . '/thumbs/' . $video->filename . '.jpg');
Filesystem::Delete(UPLOAD_PATH . '/mobile/' . $video->filename . '.mp4');
Filesystem::Close();
} catch (Exception $e) {
App::Alert('Error During Video Removal', "Unable to delete video files for: {$video->filename}. The video has been removed from the system, but the files still remain. Error: " . $e->getMessage());
}
// Delete Comments
$query = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE video_id = {$video_id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Comment::Delete($row->comment_id);
}
// Delete Ratings
$query = "SELECT rating_id FROM " . DB_PREFIX . "ratings WHERE video_id = {$video_id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Rating::Delete($row->rating_id);
}
// Delete Favorites
$query = "SELECT fav_id FROM " . DB_PREFIX . "favorites WHERE video_id = {$video_id}";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Favorite::Delete($row->fav_id);
}
// Delete Flags
$query = "SELECT flag_id FROM " . DB_PREFIX . "flags WHERE id = {$video_id} AND type = 'video'";
$result = $db->Query($query);
while ($row = $db->FetchObj($result)) {
Flag::Delete($row->flag_id);
}
// Delete Video
$query = "DELETE FROM " . DB_PREFIX . "videos WHERE video_id = {$video_id}";
$db->Query($query);
}