hierarchy

MySQL Recursive get all child from parent

拜拜、爱过 提交于 2019-11-28 10:15:37
i have this case using recursive query on Mysql to find lv 2 and lv3 child on one table... database structure i'm using: id name parent 1 A 0 2 B 0 3 C 0 4 D 1 5 E 1 6 F 2 7 G 2 8 H 3 9 I 3 10 J 4 11 K 4 The result i was expecting, when filtering the data, where id=1, it will generate the result i'm expecting. id name parent 4 D 1 5 E 1 10 J 4 11 K 4 or this is the illustration. i've been looking everywhere, and reading this http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ , but i didn't find the result i was looking for.. any help would be appreciated, thanks SELECT * FROM

LINQ sort a flat list based on childorder

£可爱£侵袭症+ 提交于 2019-11-28 09:44:05
I am currently trying to figure out a good way to sort my elements with LINQ and C#, but I am kinda failing to do so. For the problem let assume you have the following Table ---TempTable ID (int) ParentID (int) Name (varchar) SortOrder (int) The ID and ParentID are related to each other and give me a self hierachical data structure. The root elements have a null in the ID Field. The SortOrder is only a portion of the whole table and based on the ParentID, so the elements that share the same ParentID do have 1, 2, 3 in it. Lets further assume the following data: ID = 1 ParentID = null Name =

Dynamic Array traversal in PHP

江枫思渺然 提交于 2019-11-28 09:13:13
问题 I want to build a hierarchy from a one-dimensional array and can (almost) do so with a more or less hardcoded code. How can I make the code dynamic? Perhaps with while(isset($array[$key])) { ... } ? Or, with an extra function? Like this: $out = my_extra_traverse_function($array,$key); function array_traverse($array,$key=NULL) { $out = (string) $key; $out = $array[$key] . "/" . $out; $key = $array[$key]; $out = $array[$key] ? $array[$key] . "/" . $out : ""; $key = $array[$key]; $out = $array[

How to use CTE to map parent-child relationship?

天涯浪子 提交于 2019-11-28 08:58:51
问题 Say I have a table of items representing a tree-like structured data, and I would like to continuously tracing upward until I get to the top node, marked by a parent_id of NULL. What would my MS SQL CTE (common table expression) look like? For example, if I were to get the path to get to the top from Bender , it would look like Comedy Futurama Bender Thanks, and here's the sample data: DECLARE @t Table(id int, description varchar(50), parent_id int) INSERT INTO @T SELECT 1, 'Comedy', null

Depth-first flattened collection of an object hierarchy using LINQ

廉价感情. 提交于 2019-11-28 08:58:50
问题 I have an object hierarchy (MasterNode -> ChildNodes) where master and child nodes are of the same type, and there are only two levels (top level and children) like this ('A' is parent of D,E and F, 'B' is parent of G, etc) A--+ | D | E | F | B--+ | G | C--+ H I Suppose I have a MasterNodes as an IEnumerable of the parent objects (A,B,C) and given a parent object X I can get an IEnumerable of its children by X.children I know that I can enumerate all of the leaf (child nodes) with the

Make *ALL* Wordpress Categories use their Parent Category Template

自闭症网瘾萝莉.ら 提交于 2019-11-28 06:01:55
I want to change the default template hierarchy behavior, and force all subcategory level pages that don't have their own category template file to refer to their parent category template file. In my other post, Richard M. gave an excellent answer that solved the problem for an individual subcategory. Does anyone know how to abstract it? function myTemplateSelect() { if (is_category()) { if (is_category(get_cat_id('projects')) || cat_is_ancestor_of(get_cat_id('projects'), get_query_var('cat'))) { load_template(TEMPLATEPATH . '/category-projects.php'); exit; } } } add_action('template_redirect'

ASP.NET MVC 3 Treeview

妖精的绣舞 提交于 2019-11-28 04:47:09
I need to display a Treeview in my MVC3 application. There will be a self referencing hierarchical table (Folders) and another table linked to it (Documents.) (So Folders can have N-subFolders and any folder/sub folder can have many documents.) I have looked into using third party vendors such as Telerik, DJME and MVC Controls Toolkit. While all nice packages, I'm uneasy about the licences, and since i'm new to MVC (and programming in general,) I find their documentation lacking to get the right display working. I've also looked at the heavily referenced blogs on TreeViews: TreeViewHelper and

SQL Server OPENJSON read nested json

ⅰ亾dé卋堺 提交于 2019-11-28 03:29:31
I have some json that I would like to parse in SQL Server 2016. There is a hierarchy structure of Projects->Structures->Properties. I would like to write a query that parses the whole hierarchy but I don't want to specify any elements by index number ie I don't want to do anything like this: openjson (@json, '$[0]') or openjson (@json, '$.structures[0]') I had this idea that I could read the values of the top level project objects along with the json string that represents the structures below it, which could then be parsed separately. The problem is that the following code does not work:

How to design a hierarchical role based access control system

左心房为你撑大大i 提交于 2019-11-28 02:44:10
Basic deal is, we have a custom built "kickstart" for our projects. For this we are looking at redoing the user control. I know there are a lot of questions out there about general rbac, but I cannot find any on hierarchical rbac? Our requirements are: Roles can be assigned to group permissions If the role does not have a permission entry then it is automatically denied A user can be given overriding permissions A users overriding permissions is either a grant or deny If a user is explicitly denied a permission no matter what roles say "granted" the override wins. Users can have multiple roles

Whose view is not in the window hierarchy issue?

拈花ヽ惹草 提交于 2019-11-28 01:18:32
问题 Warning: Attempt to present on whose view is not in the window hierarchy! Yes I have looked at the other questions and answers before posting this question. They have not helped me resolve this. Here's what I am doing. I am calling on my singleton class socialHelper to display an action sheet, where postToFacebook method is an option to select. When clicking on this action, I get the Warning above and the postToFacebook is not displayed. I'm calling this from a UIViewController with the