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
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
crash3k  
View profile   Translate to Translated (View Original)
 More options 3 July, 19:56
From: crash3k <schilling...@googlemail.com>
Date: Fri, 3 Jul 2009 11:56:37 -0700 (PDT)
Local: Fri 3 July 2009 19:56
Subject: 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


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

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