Error with render_array on Tree Connector

Hi Guys

I have the following PHP code to generate a tree via the Tree Connector

$sql = "SELECT id,test1,test2 FROM test;";   //get 3 columns from table
$res = mysql_query($sql);
$data = array();
while($row = mysql_fetch_assoc($res))
{
	$data[] = $row;
}

print_r($data);
$conn = new TreeConnector('dummy');  //create a tree connector
$conn->render_array($data,'id','test1,test2');  //render via array

I get the folllowing error code any time I try this :

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65484 bytes) in /var/www/html/jenny/admin/includes/dhtmlxconnector/tools.php on line 80

I’ve tried many different data structures with each giving this error.

Hi DHTMLX, Please can you guys help. I’m sure this is some kind of a bug? Am I using the render_array correctly? I don’t have many examples of how to initialize it.

Hi,

Probably you will need to increase PHP’s memory limits. You can modify php.ini or use ini_set() php method, for example:
ini_set(‘memory_limit’, ‘512M’);

Am I using the render_array correctly?

If test1 or test2 is the field that contains ids of parent items you are using method incorrectly. The field with parent ids should be set in the 4th parameter of the render_array method.

Here is the example how to update 01_basic_connector.php for the dhtmlxConnector/php/samples/tree/01_basic.html sample:


$sql = “SELECT taskId,taskName,parentId FROM tasks;”; //get 3 columns from table
$res = mysql_query($sql);
$data = array();
while($row = mysql_fetch_assoc($res))
{
$data[] = $row;
}

$tree = new TreeConnector("");
$tree->render_array($data, “taskId”, “taskName”,"",“parentId”);

Hi Alexandra

I have tried lifting the PHP memory_limit to 512MB but it gives the same problem.

Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 65484 bytes) in /var/www/html/jenny/admin/includes/dhtmlxconnector/tools.php on line 80

I’ve enabled logged with no effect.
If I read directly from the test table it works. The problem is I don’t need that data its just for testing. I need to be able to use an array from PHP that has no bearing on the DB.

This is my test code now:

$data[] = array('id'=>1,'test'=>'technical','test2'=>'test');
$data[] = array('id'=>2,'test'=>'customer','test2'=>'test');
$data[] = array('id'=>3,'test'=>'setup','test2'=>'test');
$data[] = array('id'=>4,'test'=>'package','test2'=>'test');
$data[] = array('id'=>5,'test'=>'setup','test2'=>'test');
$data[] = array('id'=>6,'test'=>'adslacc','test2'=>'test');

print_r($data);
$conn = new TreeConnector('dummy');
$conn->enable_log("temp.log",true);
$conn->render_array($data,'id','test1,test2');

This does not work:

Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/html/jenny/admin/includes/dhtmlxconnector/tree_connector.php on line 130

I think it is a problem.

Hi,

We have not managed to reproduce the problem with the sample that you provided. However, there is a mistake (except parent id fields that I mentioned in the previous reply):

You define “test” field in the array and set “test1” in render_array method.

$conn->render_array($data,‘id’,‘test,test2’);

Also you try to download the latest connector.

Hi Alexandra

Thanks that was a bug in my test code but it still gives the original error now:

This is my PHP :

PHP Version 5.5.0
System:Linux 2.6.32-279.22.1.el6.i686 #1 SMP i686

I have attached a file that does NOT run on my system:

Fatal error: Maximum execution time of 30 seconds exceeded in test/dhtmlxdebug/dhtmlxconnector/tree_connector.php on line 26
index.zip (353 Bytes)

Hi,

please try use the latest connector version. It can be downloaded here:

github.com/DHTMLX/connector-php

Hope it’ll fix the problem

Worked !
Damn sorry about that. My version was downloaded about a month ago? Not sure when they fixed it.

Hi,

No worries )

The bug is not fixed in the official version yet. And github version is the latest dev version that contains bug fixes and feature improvements that have been made since of official release.

Hi Alexandra. Now all my other render_sql calls don’t work anymore.

Fatal error: Uncaught exception ‘Exception’ with message ‘MySQL operation failed Column ‘id’ in field list is ambiguous’ in XXXXXXXincludes/dhtmlxconnector/db_common.php:1085 Stack trace: #0 XXXXXXXincludes/dhtmlxconnector/db_common.php(744): MySQLDBDataWrapper->query(‘SELECT id,`pa…’) #1 XXXXXXXincludes/dhtmlxconnector/strategy.php(172): DBDataWrapper->select(Object(DataRequestConfig)) #2 XXXXXXXincludes/dhtmlxconnector/base_connector.php(662): TreeRenderStrategy->render_set(Resource id #39, ‘TreeGridDataIte…’, NULL, ‘?’, Object(DataConfig), Array) #3 XXXXXXXincludes/dhtmlxconnector/base_connector.php(670): Connector->render_set(Resource id #39) #4 XXXXXXXincludes/dhtmlxconnector/base_connector.php(513): Connector->output_as_xml(Resource id #39) #5 XXXXXXXincludes/dhtmlxconnector/base_connector.php(447): Connector->render() #6 XXXXXXXservices/services in XXXXXXXincludes/dhtmlxconnector/db_common.php on line 1085

Hi Alexandra

The new version library also does not do parent id implementation at all. All the XML output says :
child=“-1” no matter what the parent_id column is set to.
Attached the file that does not work.

Regards
index.php.zip (418 Bytes)

Hi,

parent id should be set in the 5th parameter. So, you should call render_array as in:

$conn->render_array($data,‘id’,‘test,test2’,’’,‘pid’);

instead of

$conn->render_array($data,‘id’,‘test,test2’,‘pid’);

Now all my other render_sql calls don’t work anymore.

Locally, we can not reproduce the problem. Could you provide a demo please ?