dhtmlxconnector:init [DHX documentation]

PHP Connector DHTMLX

Initialization

To use functionality of DHTMLX Connector, first you should initialize it.
Generally, both client- and server-sides are concerned in it.

client-side

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

  1. Specify connector file in load (or loadXML) 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. Include connector.js file (located in dhtmlxConnector_php/codebase).
  2. Specify connector file in load (or loadXML) method of a component.
  3. Initialize dhtmlxDataProcessor on client-side (read more about it here).

    //index.html
    <script src="codebase/connector/connector.js"></script>
    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 for all components

server-side

  1. Include appropriate connector file into the page.
  2. Create Database connection.
  3. Instantiate connector object. Linking variable is a mandatory parameter in all constructors. The second parameter(database type)- optional. By default “MySQL”. Other possible variants see here.
  4. The last step is data configuration.

    //my_connector.php
    require("connector/grid_connector.php");// connector file
    $res=mysql_connect("localhost","root","");// db connection
    mysql_select_db("myDatabase"); // db connection
    $gridConn = new GridConnector($res,"MySQL"); // connector object;    parameters: db connection and the type of the using db
    $gridConn->render_table("mytable","item_id","item_nm,item_cd");// data configuration

Samples of server-side initialization for all components