Check documentation for the latest version of dhtmlxSuite Initializing PHP Connector DHTMLX Docs

Initializing PHP Connector

To use the functionality of DHTMLX Connector, firstly you should initialize it.

Generally, both client and server sides are concerned in it.

Client side

If you need just to load data from database (with or without data preprocessing)

Specify connector file in the load method of a component.

//index.html
myGrid = new dhtmlXGridObject("someContainer");// initializes grid
...
myGrid.load("my_connector.php");

If you need to perform any update operations

  1. Specify the connector file in the load method of a component.
  2. Initialize dhtmlxDataProcessor on the client side (read more about it here).
//index.html
myGrid = new dhtmlXGridObject("someContainer");// initializes grid
...
myGrid.load("my_connector.php");
myDP = new dataProcessor("myconnector.php");// initializes dhtmlxDataProcessor
myDP.init(myGrid);

Samples of Client-Side Initialization

Server side

  1. Include an appropriate connector file into the page.
  2. Create Database connection.
  3. Specify the UTF-8 character encoding for database.
  4. Instantiate the connector object. Linking variable is a mandatory parameter in all constructors. The second parameter(database type) is optional. It's “MySQL” by default. Other possible variants you may see here.
  5. The last step is data configuration.
//my_connector.php
require("connector/grid_connector.php");// connector file
$res=new PDO("mysql:dbname=myDatabase;host=localhost","root","");// db connection
// connector object; parameters: db connection and the type of the used db
$gridConn = new GridConnector($res,"MySQL"); 
$gridConn->render_table("mytable","item_id","item_nm,item_cd");// data configuration

Samples of Server-Side Initialization

Back to top