10 defined(
'JPATH_PLATFORM') or die;
91 protected $_cache = array();
99 protected $_debug = 0;
110 public function debug($level)
112 $this->_debug = (int) $level;
126 public function getPath($pk = null, $diagnostic =
false)
128 $k = $this->_tbl_key;
129 $pk = (is_null($pk)) ? $this->$k : $pk;
132 $select = ($diagnostic) ?
'p.' . $k .
', p.parent_id, p.level, p.lft, p.rgt' :
'p.*';
133 $query = $this->_db->getQuery(
true)
135 ->from($this->_tbl .
' AS n, ' . $this->_tbl .
' AS p')
136 ->where(
'n.lft BETWEEN p.lft AND p.rgt')
137 ->where(
'n.' . $k .
' = ' . (
int) $pk)
140 $this->_db->setQuery($query);
142 return $this->_db->loadObjectList();
156 public function getTree($pk = null, $diagnostic =
false)
158 $k = $this->_tbl_key;
159 $pk = (is_null($pk)) ? $this->$k : $pk;
162 $select = ($diagnostic) ?
'n.' . $k .
', n.parent_id, n.level, n.lft, n.rgt' :
'n.*';
163 $query = $this->_db->getQuery(
true)
165 ->from($this->_tbl .
' AS n, ' . $this->_tbl .
' AS p')
166 ->where(
'n.lft BETWEEN p.lft AND p.rgt')
167 ->where(
'p.' . $k .
' = ' . (
int) $pk)
170 return $this->_db->setQuery($query)->loadObjectList();
184 public function isLeaf($pk = null)
186 $k = $this->_tbl_key;
187 $pk = (is_null($pk)) ? $this->$k : $pk;
188 $node = $this->_getNode($pk);
198 return (($node->rgt - $node->lft) == 1);
215 public function setLocation($referenceId, $position =
'after')
218 if (($position !=
'before') && ($position !=
'after') && ($position !=
'first-child') && ($position !=
'last-child'))
220 throw new InvalidArgumentException(sprintf(
'%s::setLocation(%d, *%s*)', get_class($this), $referenceId, $position));
224 $this->_location = $position;
225 $this->_location_id = $referenceId;
241 public function move($delta, $where =
'')
243 $k = $this->_tbl_key;
246 $query = $this->_db->getQuery(
true)
249 ->where(
'parent_id = ' . $this->parent_id);
253 $query->where($where);
258 $query->where(
'rgt > ' . $this->rgt)
264 $query->where(
'lft < ' . $this->lft)
266 $position =
'before';
269 $this->_db->setQuery($query);
270 $referenceId = $this->_db->loadResult();
274 return $this->moveByReference($referenceId, $position, $pk);
295 public function moveByReference($referenceId, $position =
'after', $pk = null)
300 echo
"\nMoving ReferenceId:$referenceId, Position:$position, PK:$pk";
304 $k = $this->_tbl_key;
305 $pk = (is_null($pk)) ? $this->$k : $pk;
308 if (!$node = $this->_getNode($pk))
315 $query = $this->_db->getQuery(
true)
318 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
320 $children = $this->_db->setQuery($query)->loadColumn();
325 $this->_logtable(
false);
330 if (in_array($referenceId, $children))
332 $e =
new UnexpectedValueException(
333 sprintf(
'%s::moveByReference(%d, %s, %d) parenting to child.', get_class($this), $referenceId, $position, $pk)
350 ->update($this->_tbl)
351 ->set(
'lft = lft * (-1), rgt = rgt * (-1)')
352 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
353 $this->_db->setQuery($query);
355 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
362 ->update($this->_tbl)
363 ->set(
'lft = lft - ' . (
int) $node->width)
364 ->where(
'lft > ' . (
int) $node->rgt);
365 $this->_db->setQuery($query);
367 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
371 ->update($this->_tbl)
372 ->set(
'rgt = rgt - ' . (
int) $node->width)
373 ->where(
'rgt > ' . (
int) $node->rgt);
374 $this->_db->setQuery($query);
376 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
382 if (!$reference = $this->_getNode($referenceId))
391 if (!$repositionData = $this->_getTreeRepositionData($reference, $node->width, $position))
404 ->select($this->_tbl_key .
', parent_id, level, lft, rgt')
406 ->where(
'parent_id = 0')
408 $this->_db->setQuery($query, 0, 1);
409 $reference = $this->_db->loadObject();
414 $this->_logtable(
false);
419 if (!$repositionData = $this->_getTreeRepositionData($reference, $node->width,
'last-child'))
434 ->update($this->_tbl)
435 ->set(
'lft = lft + ' . (
int) $node->width)
436 ->where($repositionData->left_where);
437 $this->_db->setQuery($query);
439 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
443 ->update($this->_tbl)
444 ->set(
'rgt = rgt + ' . (
int) $node->width)
445 ->where($repositionData->right_where);
446 $this->_db->setQuery($query);
448 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
454 $offset = $repositionData->new_lft - $node->lft;
455 $levelOffset = $repositionData->new_level - $node->level;
459 ->update($this->_tbl)
460 ->set(
'rgt = ' . (
int) $offset .
' - rgt')
461 ->set(
'lft = ' . (
int) $offset .
' - lft')
462 ->set(
'level = level + ' . (
int) $levelOffset)
464 $this->_db->setQuery($query);
466 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
469 if ($node->parent_id != $repositionData->new_parent_id)
471 $query = $this->_db->getQuery(
true)
472 ->update($this->_tbl);
475 $fields = $this->getFields();
477 if (property_exists($this,
'title') && $this->title !== null)
479 $query->set(
'title = ' . $this->_db->quote($this->title));
482 if (array_key_exists(
'alias', $fields) && $this->alias !== null)
484 $query->set(
'alias = ' . $this->_db->quote($this->alias));
487 $query->set(
'parent_id = ' . (
int) $repositionData->new_parent_id)
488 ->where($this->_tbl_key .
' = ' . (
int) $node->$k);
489 $this->_db->setQuery($query);
491 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_MOVE_FAILED');
498 $this->parent_id = $repositionData->new_parent_id;
499 $this->level = $repositionData->new_level;
500 $this->lft = $repositionData->new_lft;
501 $this->rgt = $repositionData->new_rgt;
516 public function delete($pk = null, $children =
true)
518 $k = $this->_tbl_key;
519 $pk = (is_null($pk)) ? $this->$k : $pk;
522 $this->_observers->update(
'onBeforeDelete', array($pk));
532 if ($this->_trackAssets)
534 $name = $this->_getAssetName();
538 if (!$asset->_lock())
544 if ($asset->loadByName($name))
547 if (!$asset->delete(null, $children))
549 $this->setError($asset->getError());
558 $this->setError($asset->getError());
566 $node = $this->_getNode($pk);
576 $query = $this->_db->getQuery(
true);
583 ->delete($this->_tbl)
584 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
585 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
589 ->update($this->_tbl)
590 ->set(
'lft = lft - ' . (
int) $node->width)
591 ->where(
'lft > ' . (
int) $node->rgt);
592 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
596 ->update($this->_tbl)
597 ->set(
'rgt = rgt - ' . (
int) $node->width)
598 ->where(
'rgt > ' . (
int) $node->rgt);
599 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
606 ->delete($this->_tbl)
607 ->where(
'lft = ' . (
int) $node->lft);
608 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
612 ->update($this->_tbl)
613 ->set(
'lft = lft - 1')
614 ->set(
'rgt = rgt - 1')
615 ->set(
'level = level - 1')
616 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
617 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
621 ->update($this->_tbl)
622 ->set(
'parent_id = ' . (
int) $node->parent_id)
623 ->where(
'parent_id = ' . (
int) $node->$k);
624 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
628 ->update($this->_tbl)
629 ->set(
'lft = lft - 2')
630 ->where(
'lft > ' . (
int) $node->rgt);
631 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
635 ->update($this->_tbl)
636 ->set(
'rgt = rgt - 2')
637 ->where(
'rgt > ' . (
int) $node->rgt);
638 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_DELETE_FAILED');
645 $this->_observers->update(
'onAfterDelete', array($pk));
663 public function check()
665 $this->parent_id = (int) $this->parent_id;
671 if ($this->parent_id == 0)
673 throw new UnexpectedValueException(sprintf(
'Invalid `parent_id` [%d] in %s', $this->parent_id, get_class($this)));
676 $query = $this->_db->getQuery(
true)
677 ->select(
'COUNT(' . $this->_tbl_key .
')')
679 ->where($this->_tbl_key .
' = ' . $this->parent_id);
681 if (!$this->_db->setQuery($query)->loadResult())
683 throw new UnexpectedValueException(sprintf(
'Invalid `parent_id` [%d] in %s', $this->parent_id, get_class($this)));
686 catch (UnexpectedValueException $e)
714 public function store($updateNulls =
false)
716 $k = $this->_tbl_key;
719 $this->_observers->update(
'onBeforeStore', array($updateNulls, $k));
724 echo
"\n" . get_class($this) .
"::store\n";
725 $this->_logtable(
true,
false);
733 if (empty($this->$k))
740 if ($this->_location_id >= 0)
750 if ($this->_location_id == 0)
753 $query = $this->_db->getQuery(
true)
754 ->select($this->_tbl_key .
', parent_id, level, lft, rgt')
756 ->where(
'parent_id = 0')
758 $this->_db->setQuery($query, 0, 1);
759 $reference = $this->_db->loadObject();
764 $this->_logtable(
false);
772 if (!$reference = $this->_getNode($this->_location_id))
782 if (!($repositionData = $this->_getTreeRepositionData($reference, 2, $this->_location)))
791 $query = $this->_db->getQuery(
true)
792 ->update($this->_tbl)
793 ->set(
'lft = lft + 2')
794 ->where($repositionData->left_where);
795 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_STORE_FAILED');
799 ->update($this->_tbl)
800 ->set(
'rgt = rgt + 2')
801 ->where($repositionData->right_where);
802 $this->_runQuery($query,
'JLIB_DATABASE_ERROR_STORE_FAILED');
805 $this->parent_id = $repositionData->new_parent_id;
806 $this->level = $repositionData->new_level;
807 $this->lft = $repositionData->new_lft;
808 $this->rgt = $repositionData->new_rgt;
813 $e =
new UnexpectedValueException(sprintf(
'%s::store() used a negative _location_id', get_class($this)));
827 if ($this->_location_id > 0)
829 if (!$this->moveByReference($this->_location_id, $this->_location, $this->$k))
846 $oldCallObservers = $this->_observers->doCallObservers(
false);
848 $result = parent::store($updateNulls);
851 $this->_observers->doCallObservers($oldCallObservers);
867 $this->_observers->update(
'onAfterStore', array(&$result));
890 public function publish($pks = null, $state = 1, $userId = 0)
892 $k = $this->_tbl_key;
893 $query = $this->_db->getQuery(
true);
897 $userId = (int) $userId;
898 $state = (int) $state;
902 $compareState = ($state > 1) ? 1 : $state;
909 $pks = explode(
',', $this->$k);
914 $e =
new UnexpectedValueException(sprintf(
'%s::publish(%s, %d, %d) empty.', get_class($this), $pks, $state, $userId));
922 $checkoutSupport = (property_exists($this,
'checked_out') || property_exists($this,
'checked_out_time'));
925 foreach ($pks as $pk)
928 if (!$node = $this->_getNode($pk))
935 if ($checkoutSupport)
939 ->select(
'COUNT(' . $k .
')')
941 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt)
942 ->where(
'(checked_out <> 0 AND checked_out <> ' . (
int) $userId .
')');
943 $this->_db->setQuery($query);
946 if ($this->_db->loadResult())
949 $e =
new RuntimeException(sprintf(
'%s::publish(%s, %d, %d) checked-out conflict.', get_class($this), $pks, $state, $userId));
958 if ($node->parent_id)
963 ->from($this->_db->quoteName($this->_tbl) .
' AS n')
964 ->where(
'n.lft < ' . (
int) $node->lft)
965 ->where(
'n.rgt > ' . (
int) $node->rgt)
966 ->where(
'n.parent_id > 0')
967 ->where(
'n.published < ' . (
int) $compareState);
970 $this->_db->setQuery($query, 0, 1);
972 $rows = $this->_db->loadColumn();
976 $e =
new UnexpectedValueException(
977 sprintf(
'%s::publish(%s, %d, %d) ancestors have lower state.', get_class($this), $pks, $state, $userId)
987 ->update($this->_db->quoteName($this->_tbl))
988 ->
set(
'published = ' . (
int) $state)
989 ->where(
'(lft > ' . (
int) $node->lft .
' AND rgt < ' . (int) $node->rgt .
') OR ' . $k .
' = ' . (
int) $pk);
990 $this->_db->setQuery($query)->execute();
993 if ($checkoutSupport)
1000 if (in_array($this->$k, $pks))
1002 $this->published = $state;
1005 $this->setError(
'');
1020 public function orderUp($pk)
1022 $k = $this->_tbl_key;
1023 $pk = (is_null($pk)) ? $this->$k : $pk;
1026 if (!$this->_lock())
1033 $node = $this->_getNode($pk);
1044 $sibling = $this->_getNode($node->lft - 1,
'right');
1046 if (empty($sibling))
1057 $query = $this->_db->getQuery(
true)
1058 ->select($this->_tbl_key)
1060 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
1062 $children = $this->_db->setQuery($query)->loadColumn();
1066 ->update($this->_tbl)
1067 ->set(
'lft = lft - ' . (
int) $sibling->width)
1068 ->set(
'rgt = rgt - ' . (
int) $sibling->width)
1069 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
1070 $this->_db->setQuery($query)->execute();
1074 ->update($this->_tbl)
1075 ->set(
'lft = lft + ' . (
int) $node->width)
1076 ->set(
'rgt = rgt + ' . (
int) $node->width)
1077 ->where(
'lft BETWEEN ' . (
int) $sibling->lft .
' AND ' . (
int) $sibling->rgt)
1078 ->where($this->_tbl_key .
' NOT IN (' . implode(
',', $children) .
')');
1079 $this->_db->setQuery($query)->execute();
1081 catch (RuntimeException $e)
1103 public function orderDown($pk)
1105 $k = $this->_tbl_key;
1106 $pk = (is_null($pk)) ? $this->$k : $pk;
1109 if (!$this->_lock())
1116 $node = $this->_getNode($pk);
1126 $query = $this->_db->getQuery(
true);
1129 $sibling = $this->_getNode($node->rgt + 1,
'left');
1131 if (empty($sibling))
1134 $query->_unlock($this->_db);
1135 $this->_locked =
false;
1144 ->select($this->_tbl_key)
1146 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
1147 $this->_db->setQuery($query);
1148 $children = $this->_db->loadColumn();
1152 ->update($this->_tbl)
1153 ->set(
'lft = lft + ' . (
int) $sibling->width)
1154 ->set(
'rgt = rgt + ' . (
int) $sibling->width)
1155 ->where(
'lft BETWEEN ' . (
int) $node->lft .
' AND ' . (
int) $node->rgt);
1156 $this->_db->setQuery($query)->execute();
1160 ->update($this->_tbl)
1161 ->set(
'lft = lft - ' . (
int) $node->width)
1162 ->set(
'rgt = rgt - ' . (
int) $node->width)
1163 ->where(
'lft BETWEEN ' . (
int) $sibling->lft .
' AND ' . (
int) $sibling->rgt)
1164 ->where($this->_tbl_key .
' NOT IN (' . implode(
',', $children) .
')');
1165 $this->_db->setQuery($query)->execute();
1167 catch (RuntimeException $e)
1186 public function getRootId()
1189 $k = $this->_tbl_key;
1192 $query = $this->_db->getQuery(
true)
1195 ->where(
'parent_id = 0');
1197 $result = $this->_db->setQuery($query)->loadColumn();
1199 if (count($result) == 1)
1210 $result = $this->_db->setQuery($query)->loadColumn();
1212 if (count($result) == 1)
1217 $fields = $this->getFields();
1219 if (array_key_exists(
'alias', $fields))
1225 ->where(
'alias = ' . $this->_db->quote(
'root'));
1227 $result = $this->_db->setQuery($query)->loadColumn();
1229 if (count($result) == 1)
1235 $e =
new UnexpectedValueException(sprintf(
'%s::getRootId', get_class($this)));
1236 $this->setError($e);
1255 public function rebuild($parentId = null, $leftId = 0, $level = 0, $path =
'')
1258 if ($parentId === null)
1261 $parentId = $this->getRootId();
1263 if ($parentId ===
false)
1269 $query = $this->_db->getQuery(
true);
1272 if (!isset($this->_cache[
'rebuild.sql']))
1275 ->select($this->_tbl_key .
', alias')
1277 ->where(
'parent_id = %d');
1280 if (property_exists($this,
'ordering'))
1282 $query->order(
'parent_id, ordering, lft');
1286 $query->order(
'parent_id, lft');
1288 $this->_cache[
'rebuild.sql'] = (string) $query;
1294 $this->_db->setQuery(sprintf($this->_cache[
'rebuild.sql'], (
int) $parentId));
1296 $children = $this->_db->loadObjectList();
1299 $rightId = $leftId + 1;
1302 foreach ($children as $node)
1309 $rightId = $this->rebuild($node->{$this->_tbl_key}, $rightId, $level + 1, $path . (empty($path) ?
'' :
'/') . $node->alias);
1312 if ($rightId ===
false)
1321 ->update($this->_tbl)
1322 ->set(
'lft = ' . (
int) $leftId)
1323 ->set(
'rgt = ' . (
int) $rightId)
1324 ->set(
'level = ' . (
int) $level)
1325 ->set(
'path = ' . $this->_db->quote($path))
1326 ->where($this->_tbl_key .
' = ' . (
int) $parentId);
1327 $this->_db->setQuery($query)->execute();
1330 return $rightId + 1;
1344 public function rebuildPath($pk = null)
1346 $fields = $this->getFields();
1349 if (!array_key_exists(
'alias', $fields) || !array_key_exists(
'path', $fields))
1354 $k = $this->_tbl_key;
1355 $pk = (is_null($pk)) ? $this->$k : $pk;
1358 $query = $this->_db->getQuery(
true)
1360 ->from($this->_tbl .
' AS n, ' . $this->_tbl .
' AS p')
1361 ->where(
'n.lft BETWEEN p.lft AND p.rgt')
1362 ->where(
'n.' . $this->_tbl_key .
' = ' . (
int) $pk)
1364 $this->_db->setQuery($query);
1366 $segments = $this->_db->loadColumn();
1369 if ($segments[0] ==
'root')
1371 array_shift($segments);
1375 $path = trim(implode(
'/', $segments),
' /\\');
1379 ->update($this->_tbl)
1380 ->set(
'path = ' . $this->_db->quote($path))
1381 ->where($this->_tbl_key .
' = ' . (
int) $pk);
1383 $this->_db->setQuery($query)->execute();
1386 $this->path = $path;
1402 public function saveorder($idArray = null, $lft_array = null)
1406 $query = $this->_db->getQuery(
true);
1409 if (is_array($idArray) && is_array($lft_array) && count($idArray) == count($lft_array))
1411 for ($i = 0, $count = count($idArray); $i < $count; $i++)
1415 ->update($this->_tbl)
1416 ->where($this->_tbl_key .
' = ' . (
int) $idArray[$i])
1417 ->set(
'lft = ' . (
int) $lft_array[$i]);
1419 $this->_db->setQuery($query)->execute();
1429 return $this->rebuild();
1436 catch (Exception $e)
1455 protected function _getNode($id, $key = null)
1473 $k = $this->_tbl_key;
1478 $query = $this->_db->getQuery(
true)
1479 ->select($this->_tbl_key .
', parent_id, level, lft, rgt')
1481 ->where($k .
' = ' . (
int) $id);
1483 $row = $this->_db->setQuery($query, 0, 1)->loadObject();
1488 $e =
new UnexpectedValueException(sprintf(
'%s::_getNode(%d, %s) failed.', get_class($this), $id, $key));
1489 $this->setError($e);
1495 $row->numChildren = (int) ($row->rgt - $row->lft - 1) / 2;
1496 $row->width = (int) $row->rgt - $row->lft + 1;
1517 protected function _getTreeRepositionData($referenceNode, $nodeWidth, $position =
'before')
1520 if (!is_object($referenceNode) || !(isset($referenceNode->lft) && isset($referenceNode->rgt)))
1531 $k = $this->_tbl_key;
1532 $data =
new stdClass;
1538 $data->left_where =
'lft > ' . $referenceNode->lft;
1539 $data->right_where =
'rgt >= ' . $referenceNode->lft;
1541 $data->new_lft = $referenceNode->lft + 1;
1542 $data->new_rgt = $referenceNode->lft + $nodeWidth;
1543 $data->new_parent_id = $referenceNode->$k;
1544 $data->new_level = $referenceNode->level + 1;
1548 $data->left_where =
'lft > ' . ($referenceNode->rgt);
1549 $data->right_where =
'rgt >= ' . ($referenceNode->rgt);
1551 $data->new_lft = $referenceNode->rgt;
1552 $data->new_rgt = $referenceNode->rgt + $nodeWidth - 1;
1553 $data->new_parent_id = $referenceNode->$k;
1554 $data->new_level = $referenceNode->level + 1;
1558 $data->left_where =
'lft >= ' . $referenceNode->lft;
1559 $data->right_where =
'rgt >= ' . $referenceNode->lft;
1561 $data->new_lft = $referenceNode->lft;
1562 $data->new_rgt = $referenceNode->lft + $nodeWidth - 1;
1563 $data->new_parent_id = $referenceNode->parent_id;
1564 $data->new_level = $referenceNode->level;
1569 $data->left_where =
'lft > ' . $referenceNode->rgt;
1570 $data->right_where =
'rgt > ' . $referenceNode->rgt;
1572 $data->new_lft = $referenceNode->rgt + 1;
1573 $data->new_rgt = $referenceNode->rgt + $nodeWidth;
1574 $data->new_parent_id = $referenceNode->parent_id;
1575 $data->new_level = $referenceNode->level;
1582 echo
"\nRepositioning Data for $position" .
"\n-----------------------------------" .
"\nLeft Where: $data->left_where"
1583 .
"\nRight Where: $data->right_where" .
"\nNew Lft: $data->new_lft" .
"\nNew Rgt: $data->new_rgt"
1584 .
"\nNew Parent ID: $data->new_parent_id" .
"\nNew Level: $data->new_level" .
"\n";
1602 protected function _logtable($showData =
true, $showQuery =
true)
1604 $sep =
"\n" . str_pad(
'', 40,
'-');
1609 $buffer .=
"\n" . $this->_db->getQuery() . $sep;
1614 $query = $this->_db->getQuery(
true)
1615 ->select($this->_tbl_key .
', parent_id, lft, rgt, level')
1617 ->order($this->_tbl_key);
1618 $this->_db->setQuery($query);
1620 $rows = $this->_db->loadRowList();
1621 $buffer .= sprintf(
"\n| %4s | %4s | %4s | %4s |", $this->_tbl_key,
'par',
'lft',
'rgt');
1624 foreach ($rows as $row)
1626 $buffer .= sprintf(
"\n| %4s | %4s | %4s | %4s |", $row[0], $row[1], $row[2], $row[3]);
1645 protected function _runQuery($query, $errorMessage)
1650 $this->_db->setQuery($query)->execute();
1659 catch (Exception $e)