Generating Depth based tree from Hierarchical Data in MySQL (no CTEs)

You can do it in a single call from php to mysql if you use a stored procedure: Example calls mysql> call category_hier(1); +——–+—————+—————+———————-+——-+ | cat_id | category_name | parent_cat_id | parent_category_name | depth | +——–+—————+—————+———————-+——-+ | 1 | Location | NULL | NULL | 0 | | 3 | USA | 1 | Location … Read more

Hierarchical/tree database for directories path in filesystem

Here’s a quick closure table example for SQLite. I’ve not included the statements for inserting items into an existing tree. Instead, I’ve just created the statements manually. You can find the insert and delete statements in the Models for hierarchical data slides. For the sake of my sanity when inserting the IDs for the directories, … Read more

WPF Treeview Databinding Hierarchal Data with mixed types

Since you want the elements in the TreeView to have a list of children that consists of both Categories Products, you will want your Category ViewModel to have a collection that consists of both Categories and Products. For example, you could use a CompositeCollection to combine your existing collections: public class Category { public string … Read more

Oracle SYS_CONNECT_BY_PATH equivalent query into SQL Server

CREATE TABLE #MY_TABLE ( ID INT ,ID_FATHER INT ,COL_X INT ) CREATE TABLE #MY_TABLE_BIS ( MY_ID INT ,X VARCHAR(50) ) CREATE TABLE #OTHER_TABLE ( MY_ID INT ,[ROOT] VARCHAR(50) ) CREATE TABLE #BIG_TABLE ( AN_ID INT ) go DECLARE @MAXDEPTH INT = 10 ;WITH cte_prepare AS ( SELECT ID ,ID_FATHER ,TB.X ,OT.[ROOT] FROM #MY_TABLE T LEFT … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)