Elementary DB operations with Connector

dhtmlxConnector allows executing some actions against DB.

SQL queries

DBWrapper object can be accessed as:

<cfset conn.sql>

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

<cfset conn.sql.query("DELETE FROM some_table WHERE ID=1")>
//or
<cfset res=conn.sql.query("SELECT * FROM some_table WHERE ID=1")>
<cfset data=conn.sql.get_next(res)>
//or
<cfset conn.sql.query("INSERT INTO some_table(type) VALUES('simple')")>
<cfset id = conn.sql.get_new_id()>

INSERT query

<cfset param = structNew()>
<cfset param["value"] = '8898'>
<cfset param["name"] = 'new name'>
<cfset id = grid.do_insert(param)>

Parameters:

  • hash of values

UPDATE query

<cfset param = structNew()>
<cfset param["id"] = '8'>
<cfset param["value"] = '8898'>
<cfset param["name"] = 'new name'>
<cfset grid.do_update(param)>

Parameters:

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

DELETE query

<cfset grid.do_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.

<cfset conn = createObject("component","dhtmlxConnectors.Connector").init(
    "#datasource#",
    "MySQL"
)>
<cfset conn.configure("some_table")>
<cfset param = structNew()>
<cfset param["value"] = '8898'>
<cfset param["name"] = 'new name'>
<cfset id = conn.do_insert(param)>
<cfset conn.do_delete("2")>
Back to top