-----Original Message-----
From: doctrine-user@googlegroups.com
[mailto:doctrine-user@googlegroups.com] On Behalf Of crash3k
Sent: Friday, July 03, 2009 10:57 AM
To: doctrine-user
Subject: [doctrine-user] adding a method to the nested set
Hi,
I've just started lerning Doctrine and Symfony
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.
So... here's the method a want to add:
(As you can see it's just the "getDescendants"-method
with an option to sort the result by a specified column)
public function getDescendantsSorted($depth = null, $includeNode =
false, $orderBy = '', $orderType = 'ASC') {
$baseAlias = $this->_tree->getBaseAlias();
$q = $this->_tree->getBaseQuery();
$params = array($this->record->get('lft'), $this->record->get
('rgt'));
if ($includeNode) {
$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");
}
if ($depth !== null) {
$q->addWhere("$baseAlias.level <= ?", $this->record['level'] +
$depth);
}
if ($orderBy != "")
$q->orderBy("$baseAlias.$orderBy $orderType");
$q = $this->_tree->returnQueryWithRootId($q, $this->getRootValue());
$result = $q->execute();
if (count($result) <= 0) {
return false;
}
return $result;
}
So is there a way of loading this method into the
given nested set class?
Thanks in advance!
Greetings,
CRaSH3k