nested-sets

Symfony/Propel NestedSet left/right ID corruption/adjustment

Hi folks, I have a nested set application that seems to be getting corrupted. Here's what I'm seeing: We're using nested sets for a binary tree (any node can have 2 children). It appears to be working fine, but some event causes a discrepancy. For instance, when I do a getNumberOfDescendants() for the root node, it will slowly incre...

building a navigation with nested sets, from the selected node up

Hi, I have the following tree structure using nested sets with lft & rgt values. node node node node node (selected) node node node node I'd like to build a navigation so that the tree is expanded, only to the path of the selected node, and non relevant nodes are collapsed/hidden. Using the above ...

How to reorder nodes within a node using awesome_nested_set

Hi, If I have a tree like this: Page1 ---Page1.1 ---Page1.2 ---Page1.3 Using awesome_nested_set, how would I move Page1.x up or down within the Page1 node? Thanks. ...

T-SQL: Build Nested Set From Parent-Child Relationship

I have a table that stores my Customer hierarchy with a nested set (due to the specific design of the application, I wasn't able to leverage just a Customer/Parent Customer mapping table). To simplify maintenance of this table, I've built a couple of stored procedures to handle moving nodes around and creating new nodes, but it's signif...

What is the best way to convert a doctrine nested set to an li-structure?

Hi, I'm using Doctrine NestedSet behavior. I'd like to render the tree using php to <ul>'s and <li>'s Here's an example of what the output might be: <ul> <li>Node 1</li> <li>Node 2 <ul> <li>Child 1 of Node 2</li> <li>Child 2 of Node 2 <ul> <li>Another Child</li> ...

Move node in Nested Sets tree

Hi everyone, I am working on an adjacency list with mySQL and can not (atleast by myself) do the thinking needed to make a decent enough query to be able to move a set of nodes (together with eventual children nodes) around. The table has following columns: id name left right Thanks a lot! ...

Symfony Doctrine Nested Set Path To Root Query

Is there a way in symfony to get from a doctrine nested set the whole path/route from a specified by id element to the root element in a Doctrine_Collection or array ? ...

Update ancestors in a nested set?

I am using nested sets to represent a tree in mysql, like so: Tree ID title lft rgt Given the ID of a node in the tree, what is the easiest / best way to UPDATE that node as well as all of it's ancestors? For example, let's say that the node ID (36) is 4 levels deep in the tree. I would like to update its title, as well as every par...

Installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4

I have faced serious difficulties while installing sfJqueryTreeDoctrineManagerPlugin to Symfony 1.4 w/ Doctrine ORM. The installation directly from the server did not work out like with previous plugins that I have installed: C:\path>symfony plugin:install sfJqueryTreeDoctrineManagerPlugin plugin installing plugin "sfJqueryTreeD...

PHP: Formatting multi-dimensional array as HTML?

Hi everybody, I have tried to get my head around building a recursive function to handle formatting of a unknown depth multi-dimensional array to HTML and nested Divs. I thought that it should be a piece of cake, but no. Here's what I have come up with this far: function formatHtml($array) { $var = '<div>'; foreach ($array a...

SELECT an arbitrarily deep tree that is represented by the adjacency list model in mysql?

In mysql, I have a tree that is represented using the adjacency list model. MYTREE id parent_id title I am wondering: Given the id of a node, is there any way to SELECT the entire tree beneathe that node, complete with depth information? The tree is arbitrarily deep, so I cannot say how many levels there may be. But the re...

Formtastic + nested categories

I have an article model and an category model. Category act as tree. What is the best approch to build a select list to allow the administrator to select an category from a select list to associate it later with an article ? semantic_form_for(@article) do |f| f.input :title, :as => :string f.input :content, :as => :text f.input :...

How do I go about link web content in a database with a nested set model?

My nested set table is as follows. create table depts ( id int identity(0, 1) primary key , lft int , rgt int , name nvarchar(60) , abbrv nvarchar(20) ); Test departments. insert into depts (lft, rgt, name, abbrv) values (1, 14, 'root', 'r'); insert into depts (lft, rgt, name, abbrv) values (2, 3, 'department 1', 'd...

Match all characters in group except for first and last occurrence

Say I request parent/child/child/page-name in my browser. I want to extract the parent, children as well as page name. Here are the regular expressions I am currently using. There should be no limit as to how many children there are in the url request. For the time being, the page name will always be at the end and never be omitted. ...

Looking for a decent implementation of a jquery drag-and-drop tree plugin

I've built a recursive menu using PHP and MySQL and I'm looking for a decent Jquery plugin (or tutorial) - to implement re-ordering the menu based on drag and drop. Does anyone know of any? BTW. I can do the relevant PHP, I just need something that can send drag and drop <li> elements in a nested set of <ul>s and send ajax requests. P....

Transaction safe insertion of node in nested set?

I am storing hierarchical data in mysql in the form of a nested set. myTable id, title, lft, rgt I use the following series of sql statements to insert a new node: SELECT @myLeft := lft FROM myTable WHERE ID = $id; UPDATE myTable SET rgt = rgt + 2 WHERE rgt > @myLeft; UPDATE myTable SET lft = lft + 2 WHERE lft > @myL...

Whats the fasted way to extract an array of nested objects from an array of objects in Ruby ?>

I have an array of Elements, and each element has a property :image. I would like an array of :images, so whats the quickest and least expensive way to achieve this. Is it just iteration over the array and push each element into a new array, something like this: images = [] elements.each {|element| images << element.image} ...

Why are these named_scopes causing a duplicate INNER JOIN?

I have a Model which I am using to track permissions in a hierarchical organization using the awesome_nested_set plugin. I'm running into a problem where two named_scopes, when chained together, are creating a duplication INNER JOIN. class Group < ActiveRecord::Base acts_as_nested_set has_many :memberships has_many :accounts, :thr...

MySQL query incorporation both join tables and nested sets

I have three tables, categories, tags, and taggings. The categories table is put together in the fashion of a nested set, with relevant columns id, lft, rgt, and parent_id. Tags has id and name. Taggings has tag_id and taggable_id, which refers to categories.id. If possible, I'd like for one query which returns in a field, say tag_list,...

optimizing a view for hierarchical data

I currently have a query that contains a self-join to query all the direct and indirect managers of an employee from a table that stores company organization info using the nested sets model. In this SQL notation, numbers preceded by a colon (e.g. :1) are variables: select parent.empid, parent.depth from RelationshipMgr as node join Re...