05145a47 by sayhoChun

comment reply error handled

1 parent c6547bcf
......@@ -386,7 +386,7 @@ if (! class_exists("ApiBoard"))
FROM tblComment
WHERE commentType='{$commentType}'
AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND gOrder=(SELECT gOrder + 1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND gOrder=(SELECT gOrder+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
ORDER BY gOrder DESC
LIMIT 0, 1
......@@ -396,9 +396,9 @@ if (! class_exists("ApiBoard"))
$childGroup=$child["commentGroup"];
$childOrder=$child["gOrder"];
$childDepth=$child["depth"];
if(!empty($childNo)){ //부모에게 자식이 있을 때
echo "child exists";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
......@@ -416,16 +416,34 @@ if (! class_exists("ApiBoard"))
";
$this->update($sql);
$currentNo=$this->mysql_insert_id();
$sql="
UPDATE tblComment
SET gOrder=gOrder+1
WHERE commentGroup='{$childGroup}' AND gOrder > '{$childOrder}' + 1 AND status=1
WHERE commentGroup='{$childGroup}' AND gOrder >= '{$childOrder}' + 1 AND commentNo <> '{$currentNo}' AND status=1
";
$this->update($sql);
$sql="
SELECT COUNT(*) AS count
FROM tblComment
WHERE commentGroup='{$childGroup}' AND gOrder='{$childOrder}'+1;
";
$count=$this->getValue($sql, "count");
if($count != 1){
$sql="
UPDATE tblComment
SET gOrder=gOrder+1
WHERE commentNo='{$currentNo}'
";
$this->update($sql);
}
return $this->makeResultJson("1", "저장되었습니다");
}
else{ //부모에게 자식이 없을 때
echo "no child";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
......@@ -459,10 +477,7 @@ if (! class_exists("ApiBoard"))
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
}
}
//제작사양서 저장
......
......@@ -61,8 +61,8 @@ $(document).ready(function(){
"commentType" : "FB",
"targetFk" : 1,
"userFk" : 1,
"content" : "37의 대대댓글",
"parentNo" : 37
"content" : "세 번째 부모"
},
success : function(data){
alert(data.returnmessage);
......