Check documentation for the latest version of dhtmlxSuite Elementary DB Operations with Connector DHTMLX Docs

Elementary DB Operations with Connector

dhtmlxConnector allows executing some actions against DB.

SQL queries

DBWrapper object can be accessed as:

$connector->sql

Then, it can be used in queries in the following way:

$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();

INSERT query

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

Parameters:

  • a hash of values

UPDATE query

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

Parameters:

  • a hash of values. For a successful result it must contain the identity field.

DELETE query

$connector->delete($id);

Parameters:

  • ID of the record that should be deleted

Creating a new connector

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");
Back to top