|
|
|
|
|
|
|
|
|
Re: Tree structure [message #4657 is a reply to message #4656] |
Sat, 28 February 2015 08:31   |
htManager
Messages: 456 Registered: May 2014
|
Senior Member |
|
|
I suppose that the queries are generated in the _cm_getNodeData of the class file. I copied the code from the xample file and tried to change it. But I haven't much experience in generating SQL-queries, so that I suppose that I did something wrong. Especially because I have a primary key consisting of several fields. Here is my code, maybe you can see what I am doing wrong:
$this->sql_select = 'hallen_plaetze_nodes.node_id, '
. 'hallen_plaetze_nodes.hallen_plaetze_node_desc, '
. 'hallen_plaetze_nodes.hallen_plaetze_nodes_logo_fname, '
. 'hallen_plaetze_level.hallen_plaetze_level_seq, '
. 'COUNT(child.node_id) AS child_count';
$this->sql_from = 'hallen_plaetze_nodes '
. 'LEFT JOIN hallen_plaetze_level ON '
. '(hallen_plaetze_level.verbaende_art_id=hallen_plaetze_nodes .verbaende_art_id AND '
. 'hallen_plaetze_level.verbaende_kuerzel=hallen_plaetze_nodes .verbaende_kuerzel AND '
. 'hallen_plaetze_level.halle_no=hallen_plaetze_nodes.halle_no AND '
. 'hallen_plaetze_level.hallen_plaetze_level_id=hallen_plaetze _nodes.hallen_plaetze_level_id) '
. 'LEFT JOIN hallen_plaetze_nodes AS child ON (hallen_plaetze_nodes.node_id=child.node_id_snr) ';
$this->sql_where = '';
$this->sql_groupby = 'hallen_plaetze_nodes.node_id, '
. 'hallen_plaetze_nodes.hallen_plaetze_node_desc, '
. 'hallen_plaetze_nodes.hallen_plaetze_level_id, '
. 'hallen_plaetze_level.hallen_plaetze_level_seq';
$this->sql_having = '';
$this->sql_orderby = 'hallen_plaetze_nodes.hallen_plaetze_level_id,'
. 'hallen_plaetze_nodes.node_id';
|
|
|
|
|
|
Re: Tree structure [message #4707 is a reply to message #4697] |
Fri, 24 April 2015 04:07   |
AJM
Messages: 2382 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
You have to adjust the first query to only select those entries at the top of the tree (ie: with tree_level=1). You are controlling the queries which the code issues, so it is up to you to get those queries right.
For your information I have successfully implemented tree views in my enterprise application using tables which do not include column names such as TREE_TYPE, TREE_LEVEL or TREE_NODE, and which have compound primary keys, so I know that it is definitely possible to do so. My most recent usage was to display a Bill of Materials (BOM) in my PRODUCT database which uses a single table which contains the product hierarchy, as shown below:
CREATE TABLE `product_component` (
`product_id_snr` VARCHAR(40) NOT NULL,
`product_id_jnr` VARCHAR(40) NOT NULL',
`seq_no` SMALLINT(5) UNSIGNED NOT NULL,
`revision_id_snr` VARCHAR(16) NULL DEFAULT NULL,
`revision_id_jnr` VARCHAR(16) NULL DEFAULT NULL,
`quantity` DECIMAL(15,6) UNSIGNED NOT NULL DEFAULT '1.000000',
`start_date` DATE NOT NULL DEFAULT '2000-01-01',
`end_date` DATE NULL DEFAULT '9999-12-31',
PRIMARY KEY (`product_id_snr`, `product_id_jnr`, `seq_no`)
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Tree structure [message #7567 is a reply to message #7566] |
Sun, 24 January 2021 14:57  |
htManager
Messages: 456 Registered: May 2014
|
Senior Member |
|
|
I could create a proper tree structure which is working fine. Now I wanted to create a popup3 pattern with this tree structure. In http://www.tonymarston.net/php-mysql/dialog-types.html#popup you can see that this should be a list1 pattern as popup. But in the creation process I have to choose an outer table just as in the popup4 pattern. And the popup4 *.php pattern looks the same as the *.php popup3 pattern. Is this correct or do I have to do something else?
It was my fault. I chose the wrong type. Everything works fine. Sorry for the post.
[Updated on: Mon, 25 January 2021 03:17] Report message to a moderator
|
|
|