Hello,
First excuse for my french…
I’m working with your Gantt API and I have some trouble to insert data in my database (MySql). I just find a solution and I’m not sure if it’s the good way to do it.
So this is my field name :
$gantt->render_links("my_link_table","id_link","link_1(source),link_2(target),link_3(type)");
$gantt->render_table("my_task_table","id_task","field_1(start_date),field_2(duration),field_3(text),field_4(parent),field_5(sortorder),field_6(progress)");
Every time I tried to insert a new task, all the field were empty. To solve the problem, I had to modify your function insert_query in db_common.php. I just replace $data->get_value($v[“name”] ) by $data->get_value($v[“db_name”]) and the data were instert in my database.
This is the original one:
protected function insert_query($data,$request){
$temp_n=array();
$temp_v=array();
foreach($this->config->text as $k => $v){
$temp_n[$k]=$this->escape_name($v["db_name"]);
if ($data->get_value($v["name"])===Null) {
$temp_v[$k]="Null";
} else {
$temp_v[$k]="'".$this->escape($data->get_value($v["name"]))."'";
}
}
if ($relation = $this->config->relation_id["db_name"]){
$temp_n[]=$this->escape_name($relation);
$temp_v[]="'".$this->escape($data->get_value($relation))."'";
}
if ($this->sequence){
$temp_n[]=$this->escape_name($this->config->id["db_name"]);
$temp_v[]=$this->sequence;
}
$sql="INSERT INTO ".$request->get_source()."(".implode(",",$temp_n).") VALUES (".implode(",",$temp_v).")";
return $sql;
}
This is the modified one:
protected function insert_query($data,$request){
$temp_n=array();
$temp_v=array();
foreach($this->config->text as $k => $v){
$temp_n[$k]=$this->escape_name($v["db_name"]);
if ($data->get_value($v["db_name"])===Null) {
$temp_v[$k]="Null";
} else {
$temp_v[$k]="'".$this->escape($data->get_value($v["db_name"]))."'";
}
}
if ($relation = $this->config->relation_id["db_name"]){
$temp_n[]=$this->escape_name($relation);
$temp_v[]="'".$this->escape($data->get_value($relation))."'";
}
if ($this->sequence){
$temp_n[]=$this->escape_name($this->config->id["db_name"]);
$temp_v[]=$this->sequence;
}
$sql="INSERT INTO ".$request->get_source()."(".implode(",",$temp_n).") VALUES (".implode(",",$temp_v).")";
return $sql;
}
I think it will be the same problem with your update_query.
So I just want to know if I’m doing the right thing and report the problem.
Thank you.