DHTMLX Docs & Samples Explorer

Index
dhtmlxconnector
Usage Guide

## Using connector for DB operation

When implementing custom queries , it may be necessary to execute some custom update against DB. It possible to use connector's code, which will provide abstraction from underline DB

### SQL queries

You can access DBWrapper object as

    	$connector->sql

and use it for custom queries

    	$connector->sql->query("DELETE FROM some_table WHERE ID=1");

or

    	$res = $connector->sql->query("SELECT * FROM some_table WHERE ID=1");
    	$data =  $connector->sql->get_next($res);

or

    	$connector->sql->query("INSERT INTO some_table(type) VALUES('simple')");
    	$id = $connector->sql->get_new_id();

### Operation through connector

Connector object has 3 methods for manipulation with underline table

    	$connector->delete($id);

parameter - value of ID field, for which record need to be deleted

    	$connector->update(array(
    		"type_id" => '1'
    		"type" => 'simple'
    	));

parameter - has of values, it must contain ID field for successfull result.

    	$id = $connector->insert(array(
    		"type" => "simple",
    	));

parameter - has of values

### Creating addtional output-less connectors

You can create an extra connector object on the fly and use it for DB operations

    	$temp = new Connector($db_connection);
    	$temp->configure("some_table");

    	$temp->insert(array(
    		"some1" => "value 1",
    		"some2" => "value 2"
    	));
    	$temp->delete("2");