i have problem with custom DHTMLX queries for update and delete. I am using this code to get data(it works ok):
if ($gridConn->is_select_mode()){//code for loading data
$gridConn->render_sql("SELECT * FROM user, user_liked_companies WHERE user_iduser = iduser AND company_idcompany = ".$_SESSION['company']." GROUP BY iduser",
"iduser","name,surname,phone,address,email");
} else {
//$gridConn.render_table("products","idproducts","p_name,p_price,p_des");
}
But when i am using this code for update:
function myUpdate($action){
mysql_query("UPDATE user SET name='{$action->get_value('name')}' WHERE iduser={$action->get_value('ID')}");
$action->success();
}
$gridConn->event->attach("beforeUpdate",'myUpdate');
or this one:
$gridConn->sql->attach("Update","UPDATE user SET name='{name}' WHERE iduser={iduser}");
i dont have any good results.
Can you provide a server side log for problematic operation?
docs.dhtmlx.com/doku.php?id=dhtm … tor:errors
As for code - you are using
mysql_query("UPDATE user SET name='{$action->get_value('name')}' WHERE iduser={$action->get_value('ID')}");
but there is no such field as ID above render_ command.
You need to use the same names, maybe something like
mysql_query("UPDATE user SET name='{$action->get_value('name')}' WHERE iduser={$action->get_value('iduser')}");
Also, you still need the commented render command, it need to define the names of fields ( must be in the same order as in data selection command ), so code will be able to parse data from client side
if ($gridConn->is_select_mode()){//code for loading data
$gridConn->render_sql("SELECT * FROM user, user_liked_companies WHERE user_iduser = iduser AND company_idcompany = ".$_SESSION['company']." GROUP BY iduser",
"iduser","name,surname,phone,address,email");
} else {
$gridConn.render_table("dummy", "iduser","name,surname,phone,address,email");
}
Thanks for reply but i steel have problems with updates.
I dont see any errors in log file, i have only error in DataProcessor Debuger :
Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data
Right now i have this code:
[code]$gridConn->event->attach(“beforeUpdate”,‘myUpdate’);
function myUpdate($action){
mysql_query("UPDATE user SET name='{$action->get_value('name')}' WHERE iduser={$action->get_value('iduser')}");
$action->success();
}
$gridConn->enable_log(“log.txt”);
if ($gridConn->is_select_mode()){//code for loading data
$gridConn->render_sql(“SELECT * FROM user, user_liked_companies WHERE user_iduser = iduser AND company_idcompany = “.$_SESSION[‘company’].” GROUP BY iduser”,
“iduser”,“name,surname,phone,address,email”);
} else {
$gridConn.render_table(“user”, “iduser”,“name,surname,phone,address,email”);
}[/code]
To have log file you need to add to the connector
$gridConn->enable_log("./log.txt"); //be sure that folder has write access