gpt4 book ai didi

php - 任务详细信息已保存到数据库中,但任务之间的链接详细信息未保存

转载 作者:行者123 更新时间:2023-11-29 19:16:44 24 4
gpt4 key购买 nike

自从我更改了代码

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");

关于php - 任务详细信息已保存到数据库中,但任务之间的链接详细信息未保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42645474/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com