因为我改变了代码
FROM(请注意,这部分代码同时保存了任务和链接详细信息):
$res=mysql_connect("localhost","root","");
mysql_select_db("gantt");
$gantt = new JSONGanttConnector($res);
$gantt->render_links("gantt_links","id","source,target,type");
$gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,sortorder,parent");
至 :
$connector = new JSONGanttConnector($res);
function default_values($action){
global $user_id;
$action->add_field("userId", $user_id);
}
$connector->event->attach("beforeProcessing","default_values");
$connector->render_sql("select * from gantt_tasks where userId = ".$user_id,"id","start_date,duration,text,progress,sortorder,parent");
$connector->render_sql("select * from gantt_links where userId = ".$user_id,"id","source,target,type");
$connector ->render_links("gantt_links","id","source,target,type,userId");
$connector->render_table("gantt_tasks","id","start_date,duration,text,progress,sortorder,parent,userId");
它只保存任务详细信息,但不保存任务之间的详细信息。我不明白为什么?好像忽略了代码中的第二个render_mysql。
我不认为这是一个有效的构造-
$connector->render_sql("select * from gantt_tasks where userId = ".$user_id,"id","start_date,duration,text,progress,sortorder,parent");
$connector->render_sql("select * from gantt_links where userId = ".$user_id,"id","source,target,type");
$connector ->render_links("gantt_links","id","source,target,type,userId");
$connector->render_table("gantt_tasks","id","start_date,duration,text,progress,sortorder,parent,userId");
render_table/render_sql 预计每个连接器只有一次,所以我不知道你的代码现在是如何工作的。
由于您需要对链接应用配置,因此您可以显式初始化链接连接器。这段代码
$dbtype = "MySQL";
$gantt = new JSONGanttConnector($res, $dbtype);
$gantt->render_links("gantt_links", "id", "source,target,type");
$gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,parent","");
相当于:
$gantt = new JSONGanttConnector($res, $dbtype);
$links = new JSONGanttLinksConnector($res, $dbtype);
$links->render_table("gantt_links", "id", "source,target,type");
$gantt->set_options("links", $links);
$gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,parent","");
至于按user_id过滤,我认为应该做以下事情:
function default_values($action){
global $user_id;
$action->add_field("userId", $user_id);
}
$gantt = new JSONGanttConnector($res);
$links = new JSONGanttLinksConnector($res);
$links->filter("userId", $user_id);
$links->event->attach("beforeProcessing","default_values");
$links->render_table("gantt_links", "id", "source,target,type,userId");
$gantt->set_options("links", $links);
$gantt->filter("userId", $user_id);
$gantt->event->attach("beforeProcessing","default_values");
$gantt->render_table("gantt_tasks","id","start_date,duration,text,progress,parent,userId");
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句