More info for use with CodeIgniter

Hi Guys,

I’ve been using CodeIgniter for some time but I’m new to DHTMLX and in particular the Connector library. I could only find one page in the docs about it (are there any others apart from docs.dhtmlx.com/doku.php?id=tuto … eigniter&s[]=codeigniter?)

Anyway, I used the Contact example from the Getting Started Guide and ported that to Code Igniter and that is all working fine as it is quite a simple app. Now I want to do something more complex, like return a result set from two tables and display it in the dhtmlxGrid and then allow the dhtmlxGrid to inline edit the values.

My controller looks like this, hasn’t changed much from the example and works fine for one table. I’m not sure how to change it:

[code]<?php if ( ! defined(‘BASEPATH’)) exit(‘No direct script access allowed’);

require_once(“dhtmlx/connector/grid_connector.php”);
require_once(“dhtmlx/connector/db_phpci.php”);

DataProcessor::$action_param =“dhx_editor_status”;

class Contacts extends CI_Controller {

public function index()
{
	$this->load->view('contacts');
}

public function get_urls()
{
$this->load->database();
$connector = new GridConnector($this->db, "phpCI");
$connector->configure("tblurl_custom", "id", "domain, path");
  $connector->render();

}

}[/code]

If I wasn’t using the phpCI interface I understand I could use render_sql() to perform a more complex query, but this does not seem to be available via phpCI. I saw in the docs you can create a model and use methods like get() and get_value() but wasn’t sure if this was the right approach.

Another question is should I even be using the Connector and DataProcessor with CodeIgniter, is this best practice ?

Any help on how this pieces together would be much appreciated.

Thanks,

Tim

Looks like a custom model using the CodeIgniter database class was the way to go.

I’ll keep you posted :slight_smile:

Another question is should I even be using the Connector and DataProcessor with CodeIgniter, is this best practice ?

The main advantage of Connector - it hides the details of data saving protocol. ( which is quite simple anyway ) If you have some ORM or solid model classes - you can ignore connectors, or use them only to provide data and make data saving through ORM or model class. If you are working directly with database - connectors may save you some time.

like return a result set from two tables
In case of multiple tables connector will be able to generate data at best, data saving need to be handled separately. So in this case usage of model class looks as best solution.