mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-06-05 03:09:08 -04:00
Duh, i have the count in the tag model... why do i need to do a query to count?
Added text to the description instead of return an empty string
This commit is contained in:
@@ -32,7 +32,7 @@ class Tag_Model extends ORM {
|
||||
if ($function == "children") {
|
||||
return $this->_get_tag_children($args[0], $args[1]);
|
||||
} else if ($function == "children_count") {
|
||||
return $this->_get_children_count();
|
||||
return $this->count;
|
||||
} else if ($function == "parents") {
|
||||
return ORM::factory("item", 1);
|
||||
} else {
|
||||
@@ -47,7 +47,7 @@ class Tag_Model extends ORM {
|
||||
if ($property == "title" || $property == "title_edit" || $property == "name_edit") {
|
||||
return $this->name;
|
||||
} else if ($property == "description_edit") {
|
||||
return "";
|
||||
return "There are {$this->count} items tagged.";
|
||||
} else if ($property == "owner") {
|
||||
return null;
|
||||
} else {
|
||||
@@ -77,17 +77,4 @@ class Tag_Model extends ORM {
|
||||
->where($this->foreign_key(NULL, $join_table), $this->object[$this->primary_key])
|
||||
->find_all($limit, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the total number of children.
|
||||
* @return int
|
||||
*/
|
||||
private function _get_children_count() {
|
||||
return Database::instance()
|
||||
->select("COUNT(*) AS count")
|
||||
->from("items_tags")
|
||||
->where("tag_id", $this->id)
|
||||
->get()
|
||||
->current()->count;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user