summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/tag/controllers/admin_tags.php2
-rw-r--r--modules/tag/models/tag.php19
2 files changed, 17 insertions, 4 deletions
diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php
index 6cd2f337..ed4a0366 100644
--- a/modules/tag/controllers/admin_tags.php
+++ b/modules/tag/controllers/admin_tags.php
@@ -51,7 +51,7 @@ class Admin_Tags_Controller extends Admin_Controller {
$form = tag::get_delete_form($tag);
if ($form->validate()) {
$name = $tag->name;
- Database::instance()->delete("items_tags", array("tag_id" => "$tag->id"));
+ db::build()->delete("items_tags")->where("tag_id", "=", $tag->id)->execute();
$tag->delete();
message::success(t("Deleted tag %tag_name", array("tag_name" => $name)));
log::success("tags", t("Deleted tag %tag_name", array("tag_name" => $name)));
diff --git a/modules/tag/models/tag.php b/modules/tag/models/tag.php
index f9a453be..b60f8dfc 100644
--- a/modules/tag/models/tag.php
+++ b/modules/tag/models/tag.php
@@ -63,13 +63,21 @@ class Tag_Model extends ORM {
public function save() {
$db = Database::instance();
$related_item_ids = array();
- foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+ foreach (db::build()
+ ->select("item_id")
+ ->from("items_tags")
+ ->where("tag_id", "=", $this->id)
+ ->execute() as $row) {
$related_item_ids[$row->item_id] = 1;
}
$result = parent::save();
- foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+ foreach (db::build()
+ ->select("item_id")
+ ->from("items_tags")
+ ->where("tag_id", "=", $this->id)
+ ->execute() as $row) {
$related_item_ids[$row->item_id] = 1;
}
@@ -89,7 +97,12 @@ class Tag_Model extends ORM {
public function delete() {
$related_item_ids = array();
$db = Database::Instance();
- foreach ($db->getwhere("items_tags", array("tag_id" => $this->id)) as $row) {
+
+ foreach (db::build()
+ ->select("item_id")
+ ->from("items_tags")
+ ->where("tag_id", "=", $this->id)
+ ->execute() as $row) {
$related_item_ids[$row->item_id] = 1;
}