а

Loading dhtmlXTreeObject from database table issue


#1

Hi, I am trying to load a tree from a database table and am unable to see the data onscreen. I do not see any error messages. I am a novice with php and DHTMLX.

Thanks for any help you can give.

here is my code: main.php

		var tree = new dhtmlXTreeObject("treebox", "100%", "100%", 0);
		tree.enableDragAndDrop(true);
		tree.setSkin("dhx_terrace");
		tree.attachEvent("onDrag", function() { return false; });
		tree.setImagePath("//cdn.dhtmlx.com/edge/imgs/dhxtree_material/");
		tree.load("./data/tree.php");

tree.php file

include ('../common/config.php');
include ('../common/connector/db_mysqli.php');

$tree = new schedulerConnector($res, $dbtype);
$tree->render_table("details_table","id","country_id","state_id","city_id","town_name");

ED. In console I see this error in my tree.php file. Still can’t figure out.

Fatal error: Uncaught Exception: MySQL operation failed
Unknown column ‘’ in ‘where clause’ in SOME_PATH\tree\common\connector\db_mysqli.php:14
Stack trace:
#0 SOME_PATH\tree\common\connector\db_common.php(755): MySQLiDBDataWrapper->query(‘SELECT id,`co…’)
#1 SOME_PATH\tree\common\connector\strategy.php(174): DBDataWrapper->select(Object(DataRequestConfig))
#2 SOME_PATH\tree\common\connector\base_connector.php(663): TreeRenderStrategy->render_set(Object(mysqli_result), ‘TreeDataItem’, NULL, ‘\n’, Object(DataConfig), Array)
#3 SOME_PATH\tree\common\connector\base_connector.php(671): Connector->render_set(Object(mysqli_result))
#4 SOME_PATH\htdocs\XXXXXXX\dhtmlxSchedu in SOME_PATH\tree\common\connector\db_mysqli.php on line 14


#2

In case of loading the data for the dhtmlxTree pleras,e try to use the treeConnector, not the schedulerConnector:

 $tree = new TreeConnector($res, $dbtype);

#3

Thank you for the help, I made the change and it seems to be adding a where clause to my sql statement. I am not sure why it is doing this.

===========
here is my statement:

$result = $tree_db->render_table(“country_baseline_course_topic_details”,“id”,“country_id,baseline_id,course_id,topic_title”);

===========
this is what I “print_r($sql);” in the db_msgli.php file:

SELECT id,country_id,baseline_id,course_id,topic_title FROM country_baseline_course_topic_details WHERE ( = '0' OR IS NULL )

===========
this is the error I get

Fatal error : Uncaught Exception: MySQL operation failed Unknown column ‘’ in ‘where clause’ in F:\fellon_data\apache_2.4.33\htdocs\RonTest\dhtmlxScheduler_v5.1.6_commercial\tree\common\connector\db_mysqli.php:17 Stack trace:

Thanks, any assistance is greatly appreciated.


#4

Unfortunately the problem cannot be reproduced locally. Could you please, provide a more detailed snippet of your code.


#5

Thanks for your time.

As you see in my render-sql there is no where clause, I can not see where it would add one to it.
I get this error when I Preview the tree.php in the browser.

SELECT id,country_id,baseline_id,course_id, Concat(topic_number, , topic_title) as TopicTitle FROM country_baseline_course_topic_details WHERE ( = '0' OR IS NULL )
Fatal error: Uncaught Exception: MySQL operation failed Unknown column ’ ’ in ‘field list’ in F:\some path…\db_mysqli.php:17 Stack trace:

===============
Tree.php

<?php require_once('../common/connector/tree_connector.php'); require_once('../common/connector/scheduler_connector.php'); include ('../common/config.php'); include ('../common/connector/db_mysqli.php'); $tree_db = new treeConnector($res, $dbtype); $result = $tree_db->render_sql("Select `id`,`country_id`,`baseline_id`,`course_id`, Concat(`topic_number`, ` `, `topic_title`) as `TopicTitle` from country_baseline_course_topic_details","TopicID","CountryID, CountryTitle, BaselineID, BaselineTitle, CourseID, CourseTitle, TopicTitle"); =============== RonTest_outer_drag.php =============== Integration with dhtmlxTree html, body { margin: 0px; padding: 0px; height: 100%; overflow: hidden; } #scheduler_here { background-color: white; border-left: 1px solid #EBE9E9; border-right: 1px solid #EBE9E9; }
 
 
=============== Database table =============== Table = country_baseline_course_topic_details id int(11) NOT NULL country_id int(11) NOT NULL baseline_id int(11) NOT NULL course_id int(11) NOT NULL topic_title varchar(500) NOT NULL topic_number varchar(35) NULL topic_short_title varchar(200) NULL active tinyint(1) NULL =============== Table Test Database =============== "id" "country_id" "baseline_id" "course_id" "topic_title" "topic_number" "topic_short_title" "active" "1" "1" "1" "1" "Topic 1" "No. 1" "" "1" "2" "1" "3" "2" "Topic 2" "No. 2" "" "1" "3" "2" "2" "3" "Topic 3" "No. 3" "" "1" "4" "2" "3" "5" "Topic 4" "No. 4" "" "1" "5" "3" "3" "5" "Topic 5" "No. 5" "" "1" "6" "3" "4" "6" "Topic 6" "No. 6" "" "1"