| |
doctrine-user |
You can derive a class MyNestedSet from nested set and add your own
Add a behavior MyNestedSetBehavior derived from
After, you replace actAs : [NestedSet] with actAs :
I have not tried it but it should work.
Note that if you just want to add an orderBy clause, you should be able
[mailto:doctrine-user@googlegroups.com] On Behalf Of crash3k
Hi,
I've just started lerning Doctrine and Symfony
So... here's the method a want to add:
public function getDescendantsSorted($depth = null, $includeNode =
if ($includeNode) {
if ($depth !== null) {
if ($orderBy != "")
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
if (count($result) <= 0) {
return $result;
So is there a way of loading this method into the
Thanks in advance!
Greetings,
methods in it.
Doctrine_Template_NestedSet and override the setup method and relpace
$this->_table->setOption('treeImpl', 'NestedSet'); with
$this->_table->setOption('treeImpl', 'MyNestedSet');
[MyNestedSetBehavior]
to do it by calling the setBaseQuery($q) method of the Tree just before
you call the getDescendants methos. (Where $q contains the orderBy
clause)
From: doctrine-user@googlegroups.com
Sent: Friday, July 03, 2009 10:57 AM
To: doctrine-user
Subject: [doctrine-user] adding a method to the nested set
and now I want to add a method to the nested
set-class of Doctrine but I really don't know
how to implement it.
(As you can see it's just the "getDescendants"-method
with an option to sort the result by a specified column)
false, $orderBy = '', $orderType = 'ASC') {
$baseAlias = $this->_tree->getBaseAlias();
$q = $this->_tree->getBaseQuery();
$params = array($this->record->get('lft'), $this->record->get
('rgt'));
$q->addWhere("$baseAlias.lft >= ? AND $baseAlias.rgt <= ?",
$params)->addOrderBy("$baseAlias.lft asc");
} else {
$q->addWhere("$baseAlias.lft > ? AND $baseAlias.rgt < ?", $params)-
>addOrderBy("$baseAlias.lft asc");
}
$q->addWhere("$baseAlias.level <= ?", $this->record['level'] +
$depth);
}
$q->orderBy("$baseAlias.$orderBy $orderType");
return false;
}
}
given nested set class?
CRaSH3k