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)
- 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
- Include connector.js file (located in dhtmlxConnector_php/codebase).
- Specify connector file in load (or loadXML) method of a component.
- 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);
server-side
- Include appropriate connector file into the page.
- Create Database connection.
- 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.
- 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