Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by banmidou on May 14, 2009 20:29
open dhtmlx forum
sql complex query with dhtmlxgrid-connector

Sorry for borthering you again.
This is my broblem:
<?php
    
    $res=mysql_connect("localhost","root","root");
    mysql_query("set names 'utf8'");
    mysql_select_db("ngay13");

    require("../../codebase/grid_connector.php");
    $grid = new GridConnector($res);
    $grid->enable_log("temp.log",true);
    $grid->dynamic_loading(100);
//case 1: render table: working well
            //    $gridConn->render_table("tin","id","tieude,thoigiandang,solanxem,username,tieudiem,trangthai");
//case 2:complex sql query : display data on grid well but can't delete or update
if($grid->is_select_mode())
{
$grid->render_sql("select tin.id, tin.tieude,tin.thoigiandang,tin.solanxem,user.username,tin.tieudiem,tin.trangthai from tin left join user on tin.iduser=user.id","id","tieude,thoigiandang,solanxem,username,tieudiem,trangthai");
}
else
{
$grid->sql->attach("Update","Update tin set trangthai={trangthai}, tieudiem={tieudiem} where id={id}");
//$grid->sql->attach("Delete","Delete from tin set trangthai={trangthai}, tieudiem={tieudiem} where id={id}");
}
//this is error on log: when i delete or update a row
/* row 54 marked [deleted,valid]
Initiating data sending for 54
Initiating data sending for all rows
Sending all data at once
Server url: tinxml.php?editing=true parameters

54_gr_id=54
54_c0=V%C3%AF%C2%BF%C2%BD%20sao%20%3F%C3%AF%C2%BF%C2%BDn%20%C3%AF%C2%BF%C2%BDng%20th%C3%AF%C2%BF%C2%BDch%20%3F%3F%3Fc%20y%C3%AF%C2%BF%C2%BDu%3F
54_c1=2009-02-15
54_c2=37
54_c3=banmidou
54_c4=1
54_c5=1
54_!nativeeditor_status=deleted
ids=54

Server response received details

Not an XML, probably incorrect content type specified ( must be text/xml ), or some text output was started before XML data
*/
?>

Can you help me out to resolve thist.
And i have an idea: why don't you build a forum for communication about your products. I think it will be usefull for someone like me to get support from another. That's all.
Thanks .
Answer posted by Support on May 15, 2009 03:17
Instead of

if($grid->is_select_mode())
{
... 
}
else
{
...
}


You can use 

$grid->sql->attach("Update","Update tin set trangthai={trangthai}, tieudiem={tieudiem} where id={id}"); 
$grid->render_sql("select tin.id, tin.tieude,tin.thoigiandang,tin.solanxem,user.username,tin.tieudiem,tin.trangthai from tin left join user on tin.iduser=user.id","id","tieude,thoigiandang,solanxem,username,tieudiem,trangthai"); 

a) You need to call render_sql or render_table in any case ( this command defines used table structure and names of used fields ) 
b) if you have used sql->attach it will override any auto-generated queries , so it can be used with render_sql without any side effects
c) the log which you has provide shows that delete action was executed and connector will not be able to delete records from joined tables - you need to define sql for delete action, or redefine it in any custom way through beforeDelete server side event 

Answer posted by banmidou on May 15, 2009 06:34
It works well now.
By the way, do you have any tutorial about render a combo box with dhtmxgrid-connector ?.
Thank you very much.
Answer posted by Support on May 18, 2009 04:54
Current version of connector has not built in support for combo cell types. ( they can be init and filled with data in default way - through javascript API )
Oncoming update will add ability to define options list on server side.