CakePHP 2 and dhtmlxConnector

I am working with CakePHP 2.2.2. I have been able to successfully integrate the dhtmlx grid using the example on your website.

But, when I pass a custom SQL to the connector configure method like this:

$connector->configure(“Select * from events where event_id > 3”, “event_id”, “event_id, start_date, end_date, event_name”);

I am not getting the correct result. Always all rows are appearing irrespective of the query.

Can you please help?

Thanks.

To use sql commands you need to init connector with direct DB access, instead of

$connector = new SchedulerConnector($this->Event, “PHPCake”);

you need to use

$connector = new SchedulerConnector($db, “MySQL”);

Rahulmes2012, Can you please assist me i failed to integrate dhtmlxConnector with cakephp2. I do not know how to even go about it. Thanks

Have you seen this article
docs.dhtmlx.com/doku.php?id=tuto … nd_cakephp

Dear Stanislav,

Sorry for the late response.I have used this code in the grid_data method in the Event controller:

public function grid_data(){

	ClassRegistry::init('ConnectionManager');
	$db = ConnectionManager::getDataSource('default');
	
	$this->autoRender = false;

	$connector = new GridConnector($db , "MySQL");
	$connector->configure("Select * from events", "event_id", "start_date, end_date, event_name");
	$connector->enable_log("./log.txt");
	$connector->render();
}

But, I am not able to render the grid. The grid is rendering fine if I use:

	$connector = new GridConnector($this->Event , "PHPCake");

Can you please help again? Thanks.

getDataSource returns not the original datasource object, but CakePHP wrapper class, which can’t be used with connector.

Dear Stanislav,

Thanks for the response.

I have tried a lot, but am unable to find a method to retrieve the orgininal data source object. I am using CakePHP 2.2, so getDataSource seems to be the only way to get an instance of the data source.

Can you please help me with the correct method to get it, so that I can use it with the connector?

Thanks.

Try to use
$db = ConnectionManager::getDataSource(‘default’)->getConnection( ) ;

api.cakephp.org/2.0/class-DboSou … Connection

Dear Stanislav,

Thanks. I tried with your code but am still getting a blank error box with grid not loading. I am attaching the picture.

I am using Apache 2.2.21 with PHP 5.2.17 Fast CGI.

Are you able to think of what could be the issue?

Thanks.


Blank error box is a result of empty server side response for the loading command.
To get exact error info you need to

a) check php error logs
b) enable logging for connector and check that logs

one of them will contain details about the error.