Skip to content

Commit

Permalink
Update database queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
bharat committed Dec 7, 2009
1 parent 2ff84b0 commit a6dbd25
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
31 changes: 17 additions & 14 deletions modules/comment/helpers/comment_event.php
Expand Up @@ -19,29 +19,32 @@
*/
class comment_event_Core {
static function item_deleted($item) {
Database::instance()->delete("comments", array("item_id" => $item->id));
db::build()
->delete("comments")
->where("item_id", "=", $item->id);
}

static function user_deleted($user) {
$guest = identity::guest();
Database::instance()->from("comments")
->set(array("author_id" => $guest->id,
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
db::build()
->update("comments")
->set("author_id", $guest->id)
->set("guest_email", null)
->set("guest_name", "guest")
->set("guest_url", null)
->where("author_id", "=", $user->id)
->update();
->execute();
}

static function identity_provider_changed($old_provider, $new_provider) {
$guest = identity::guest();
Database::instance()->from("comments")
->set(array("author_id" => $guest->id,
"guest_email" => null,
"guest_name" => "guest",
"guest_url" => null))
->where("1", "=", "1") // @todo: why do we do this?
->update();
db::build()
->update("comments")
->set("author_id", $guest->id)
->set("guest_email", null)
->set("guest_name", "guest")
->set("guest_url", null)
->execute();
}

static function admin_menu($menu, $theme) {
Expand Down
10 changes: 6 additions & 4 deletions modules/notification/helpers/notification_event.php
Expand Up @@ -53,14 +53,16 @@ static function item_deleted($item) {
}

static function user_deleted($user) {
ORM::factory("subscriptions")
db::build()
->delete("subscriptions")
->where("user_id", "=", $user->id)
->delete_all();
->execute();
}

static function identity_provider_changed($old_provider, $new_provider) {
ORM::factory("subscriptions")
->delete_all();
db::build()
->delete("subscriptions")
->execute();
}

static function comment_created($comment) {
Expand Down

0 comments on commit a6dbd25

Please sign in to comment.