dhtmlxconnector:data_management_how-tos_updating [DHX documentation]

PHP Connector DHTMLX

Data management how-tos (updating data)

How can I alter the default styles set for responses?

You can alter the default styles for each state, like:

dp.styles.error = ""; //avoids a special style for the 'error' response
//you should write it on the client-side (in your HTML file)
//dp -  dataProcessor object

How can I avoid updating certain field(s)?

To remove some field from updating, you can use the following technique:

//write it before '$grid->render_table'
function filter_set($action){
   $action->remove_field("id"); //the named field won't be included in CRUD operations
$grid->event->attach("beforeProcessing", filter_set);

How can I change default data processing while updating?

To affect on default data processing either on server- or client-side you should use events either of dataProcessor or dhtmlxConnector. For more details, see the chapter 'changing default precessing' in 'Client-side requirement - dataProcessor'.

How can I set custom status of operation?

Using set_status() method you can set status (custom or another predefined) of operation. Using defineAction() method of dataProcessor you can assign the appropriate processing for this status.

return true;// return false to cancel default data processing at all

How can I terminate any further processing?

Calling success() method you terminate any further action processing, i.e. data updating will be stopped and considered as finished.

function my_update($data){
   $data->success(); // marks operation as finished 

How can I change values before saving?

To customize values before saving you should use server-side events stated below:

function my_update($data){

For more information, see 'Using server-side events' in 'Making queries' guide.

How can I implement transactions?

Connector allows to use transactions for INSERT/UPDATE/DELETE operations (be sure that used DB engine has support for transactions ).
To activate transaction mode - use set_transaction_mode() method. For more details see the chapter 'Transactions' in 'Making queries' guide.

$conn->sql->set_transaction_mode("global"); //for all records inside single request
$conn->sql->set_transaction_mode("record");// for each record in request

How can I link dataProcessor with connector?

To link dataProcessor with connector you should specify connector file as a parameter of dataProcessor constructor:

dp = new dataProcessor("myconnector.php");

How can I realize multi-users sync?

To activate multi-user mode that will allow users to see changes of each other in real-time, you must add code both on client- and server-side.
On server-side, to basic initialization connector code you should add:

$conn->enable_live_update('actions_table');  //actions_table is used for sync data storage

On client-side, you should initialize dataprocessor and call setAutoUpdate():

dp.setAutoUpdate(2000);//input parameter is delay between update calls

See Multi-user sync for more information.

How can I update data on server-side?

To update data on server-side, on client-side you should initialize dataProcessor and link dhtmlxConnector to it. Default updating will be done automatically. For more details, see the guide 'Client-side requirement - dataProcessor'.

How can I save data changes made in form (simple way)?

dhtmlxConnector automatically exec CRUD operations for next patterns:

//to get data of a DB record
   GET: connector.php?action=get&id={some}
//to delete data of a DB record
   GET: connector.php?action=delete
//to update data of a DB record
   GET: connector.php?action=delete
   POST: id={some}&property_name={value}
//to insert a new record to DB
   GET: connector.php?action=insert
   POST: property_name={value}

For more details, see the guide 'Saving data changes made in form'.