Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion adding a method to the nested set

View Parsed - Show only message text

MIME-Version: 1.0
Received: by 10.100.8.17 with SMTP id 17mr434222anh.18.1246647397019; Fri, 03 
	Jul 2009 11:56:37 -0700 (PDT)
Date: Fri, 3 Jul 2009 11:56:37 -0700 (PDT)
X-IP: 92.230.230.88
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) 
	AppleWebKit/531.0 (KHTML, like Gecko) Chrome/3.0.189.0 Safari/531.0,gzip(gfe),gzip(gfe)
Message-ID: <3ce1e09f-1823-4d64-9743-847729039dbf@x3g2000yqa.googlegroups.com>
Subject: adding a method to the nested set
From: crash3k <schilling...@googlemail.com>
To: doctrine-user <doctrine-user@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

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,

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google