nested-set-model

How do I format Nested Set Model data into an array?

旧街凉风 提交于 2019-12-17 18:44:08
问题 Let's dig in the main problem right away, I have the input like this $category = array( 'A' => array('left' => 1, 'right' => 8), 'B' => array('left' => 2, 'right' => 3), 'C' => array('left' => 4, 'right' => 7), 'D' => array('left' => 5, 'right' => 6), 'E' => array('left' => 9, 'right' => 10), ); I want the output to be something like this $tree = array( array('A', 'B'), array('A', 'C', 'D'), array('E'), ); which one is the best and fast function to loop though the input array and create the

SQL Query and PHP manipulation with Nested Set Model

人走茶凉 提交于 2019-12-11 07:38:34
问题 I was reading this article, http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/. I wanted to give a simple example and then ask you how do I get the desired result? So here is the example: +---------+-----------------------------+ | product_id | product_name | +---------+-----------------------------+ | 1 | Example Product | +---------+-----------------------------+ +---------+-----------------------------+ | product_id | category_id | +---------+-----------------------------

NSPredicate on nested object / NSSet to filter the result during NSFetchRequest

一个人想着一个人 提交于 2019-12-01 14:17:43
I want a simple predicate that returns me all the groups which have mode = 0 and the mode of the enrollments in the group = 0 To be precise i need a predicate to access the nested object properties. Somehow a predicate like: [NSPredicate predicateWithFormat:@"mode = 0 AND enrollments.Enrollment.mode = 0"] the above predicate is wrong and obviously doesn't work. EDITED: I have given a go to the following predicate too but been unsuccessful. [NSPredicate predicateWithFormat:@"mode = 0 AND ALL ( SUBQUERY(enrollments,$varEnrollment,$varEnrollment.mode = 0))"] I need result which contains all

NSPredicate on nested object / NSSet to filter the result during NSFetchRequest

谁说胖子不能爱 提交于 2019-12-01 12:48:07
问题 I want a simple predicate that returns me all the groups which have mode = 0 and the mode of the enrollments in the group = 0 To be precise i need a predicate to access the nested object properties. Somehow a predicate like: [NSPredicate predicateWithFormat:@"mode = 0 AND enrollments.Enrollment.mode = 0"] the above predicate is wrong and obviously doesn't work. EDITED: I have given a go to the following predicate too but been unsuccessful. [NSPredicate predicateWithFormat:@"mode = 0 AND ALL (

Nested Set Model Php library

两盒软妹~` 提交于 2019-11-29 14:55:53
问题 Hi I need to use the nested set model to mange product categories on my site. Does anyoune know of some good pre-built PHP libraries for handling nested sets in MySQL? 回答1: You could try "Baobab", it's a library I recently released. http://www.sideralis.org/baobab/ 回答2: It's a bit old, and could do with some refactoring, but I found a PHP Class "dbtree" on PHPClasses.org, which seems to do a fair job of it - http://www.phpclasses.org/package/2547-PHP-Manipulate-database-records-in

Adjacency List Model vs Nested Set Model for MySQL hierarchical data?

放肆的年华 提交于 2019-11-28 20:38:07
There are two ways to work with hierarchy data in MySQL : Adjacency List Model Nested Set Model A major problem of the Adjacency List Model is that we need to run one query for each node to get the path of the hierarchy. In the Nested Set Model this problem does not exist, but for each added node is necessary to give a MySQL UPDATE on all others left and right value. My hierarchical data is not static data, such as product categories of e-commerce. Are constant registration of users in hierarchical sequence. In my application, while there are many constants users registration, I also need to

Is there a simple way to query the children of a node?

天涯浪子 提交于 2019-11-28 10:06:26
I've been using the crap out of the Nested Set Model lately. I have enjoyed designing queries for just about every useful operation and view. One thing I'm stuck on is how to select the immediate children (and only the children, not further descendants!) of a node. To be honest, I do know of a way - but it involves unmanageable amounts of SQL. I'm sure there is a more straightforward solution. Did you read the article you posted? It's under the heading "Find the Immediate Subordinates of a Node" SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM nested_category AS node

How do I format Nested Set Model data into an array?

烂漫一生 提交于 2019-11-28 08:48:05
Let's dig in the main problem right away, I have the input like this $category = array( 'A' => array('left' => 1, 'right' => 8), 'B' => array('left' => 2, 'right' => 3), 'C' => array('left' => 4, 'right' => 7), 'D' => array('left' => 5, 'right' => 6), 'E' => array('left' => 9, 'right' => 10), ); I want the output to be something like this $tree = array( array('A', 'B'), array('A', 'C', 'D'), array('E'), ); which one is the best and fast function to loop though the input array and create the output result like this ? Working with a nested set is a perfect case for recursion. Given your data:

Adjacency List Model vs Nested Set Model for MySQL hierarchical data?

放肆的年华 提交于 2019-11-27 11:40:58
问题 There are two ways to work with hierarchy data in MySQL: Adjacency List Model Nested Set Model A major problem of the Adjacency List Model is that we need to run one query for each node to get the path of the hierarchy. In the Nested Set Model this problem does not exist, but for each added node is necessary to give a MySQL UPDATE on all others left and right value. My hierarchical data is not static data, such as product categories of e-commerce. Are constant registration of users in

Is there a simple way to query the children of a node?

♀尐吖头ヾ 提交于 2019-11-27 03:32:49
问题 I've been using the crap out of the Nested Set Model lately. I have enjoyed designing queries for just about every useful operation and view. One thing I'm stuck on is how to select the immediate children (and only the children, not further descendants!) of a node. To be honest, I do know of a way - but it involves unmanageable amounts of SQL. I'm sure there is a more straightforward solution. 回答1: Did you read the article you posted? It's under the heading "Find the Immediate Subordinates of