summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-05-11 00:19:50 +0000
committerBharat Mediratta <bharat@menalto.com>2009-05-11 00:19:50 +0000
commitbc9bf5aa612ecd16a21d531fd6c3f2c780840bc1 (patch)
tree38ef624876f8670b408e7c50c448cb17fe961543 /core
parente947e771d37aa5ad7d7e1a0dc4ae13cc7c63ce60 (diff)
Avoid using ORM_MPTT::parents() in relative_path() so that we're not
calling ORM just to get paths. This is a 10x performance increase.
Diffstat (limited to 'core')
-rw-r--r--core/models/item.php15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/models/item.php b/core/models/item.php
index ce48c4d4..5b9211be 100644
--- a/core/models/item.php
+++ b/core/models/item.php
@@ -248,12 +248,17 @@ class Item_Model extends ORM_MPTT {
*/
public function relative_path() {
if (empty($this->relative_path)) {
- foreach ($this->parents() as $parent) {
- if ($parent->id > 1) {
- $paths[] = $parent->name;
- }
+ $paths = array();
+ foreach (Database::instance()
+ ->select("name")
+ ->from("items")
+ ->where("`left` <= {$this->left}")
+ ->where("`right` >= {$this->right}")
+ ->where("id <> 1")
+ ->orderby("left", "ASC")
+ ->get() as $row) {
+ $paths[] = $row->name;
}
- $paths[] = $this->name;
$this->relative_path = implode($paths, "/");
}
return $this->relative_path;