Skip to content

Commit

Permalink
dbInsert() now inserts correctly in both group table and link table.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemorken committed Dec 10, 2023
1 parent 5627d09 commit dfd4b97
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions data/mysql/anyTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1908,11 +1908,9 @@ public function dbInsert()
$this->dbMetaInsertOrUpdate($this->mId);

// Insert in group table, if group id is given and we have a group table
// TODO! Untested
if (isset($this->mTableNameGroupLink) &&
$this->tableExists($this->mTableNameGroupLink)) {
$gid = Parameters::get("group_id");
if ($gid && $gid != "" && $gid != "nogroup" && $this->mType != "group") {
$gid = Parameters::get("group_id");
if (($gid || $gid==0)&& $gid != "" && $gid != "nogroup" && $this->mType != "group") {
if (isset($this->mTableNameGroupLink) && $this->tableExists($this->mTableNameGroupLink)) {
$stmt = "INSERT INTO ".$this->mTableNameGroupLink." (group_id,".$this->mType."_id) ".
"VALUES ('".$gid."','".$this->mId."')";
//error_log("stmt:".$stmt);
Expand All @@ -1921,8 +1919,11 @@ public function dbInsert()
}
}
// Insert in link table, if link id is given
// TODO! Not implemented yet

$link_id = Parameters::get("link_id");
if (($link_id || $link_id==0) && $link_id != "") {
Parameters::set("add",$link_id);
$this->dbUpdateLinkList();
}
// Set result message
$this->setMessage($this->mInsertSuccessMsg);

Expand Down Expand Up @@ -2274,8 +2275,8 @@ public function dbUpdateLinkList()
foreach ($inslist as $updval) {
if ($updval && intval($id) != intval($updval)) {
$stmt = "UPDATE ".$this->mTableName." ".
"SET parent_id='".intval($id)."' ".
"WHERE ".$id_key."='".intval($updval)."'";
"SET parent_id='".intval($updval)."' ".
"WHERE ".$id_key."='".intval($id)."'";
//elog("dbUpdateLinkList(5):".$stmt);
if (!$this->query($stmt))
return null;
Expand Down

0 comments on commit dfd4b97

Please sign in to comment.