comment reply error handled
Showing
2 changed files
with
25 additions
and
10 deletions
... | @@ -386,7 +386,7 @@ if (! class_exists("ApiBoard")) | ... | @@ -386,7 +386,7 @@ if (! class_exists("ApiBoard")) |
386 | FROM tblComment | 386 | FROM tblComment |
387 | WHERE commentType='{$commentType}' | 387 | WHERE commentType='{$commentType}' |
388 | AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | 388 | AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) |
389 | AND gOrder=(SELECT gOrder + 1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | 389 | AND gOrder=(SELECT gOrder+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) |
390 | AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) | 390 | AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1) |
391 | ORDER BY gOrder DESC | 391 | ORDER BY gOrder DESC |
392 | LIMIT 0, 1 | 392 | LIMIT 0, 1 |
... | @@ -396,9 +396,9 @@ if (! class_exists("ApiBoard")) | ... | @@ -396,9 +396,9 @@ if (! class_exists("ApiBoard")) |
396 | $childGroup=$child["commentGroup"]; | 396 | $childGroup=$child["commentGroup"]; |
397 | $childOrder=$child["gOrder"]; | 397 | $childOrder=$child["gOrder"]; |
398 | $childDepth=$child["depth"]; | 398 | $childDepth=$child["depth"]; |
399 | 399 | ||
400 | |||
400 | if(!empty($childNo)){ //부모에게 자식이 있을 때 | 401 | if(!empty($childNo)){ //부모에게 자식이 있을 때 |
401 | echo "child exists"; | ||
402 | $sql=" | 402 | $sql=" |
403 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) | 403 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) |
404 | VALUES | 404 | VALUES |
... | @@ -416,16 +416,34 @@ if (! class_exists("ApiBoard")) | ... | @@ -416,16 +416,34 @@ if (! class_exists("ApiBoard")) |
416 | "; | 416 | "; |
417 | $this->update($sql); | 417 | $this->update($sql); |
418 | 418 | ||
419 | $currentNo=$this->mysql_insert_id(); | ||
420 | |||
419 | $sql=" | 421 | $sql=" |
420 | UPDATE tblComment | 422 | UPDATE tblComment |
421 | SET gOrder=gOrder+1 | 423 | SET gOrder=gOrder+1 |
422 | WHERE commentGroup='{$childGroup}' AND gOrder > '{$childOrder}' + 1 AND status=1 | 424 | WHERE commentGroup='{$childGroup}' AND gOrder >= '{$childOrder}' + 1 AND commentNo <> '{$currentNo}' AND status=1 |
423 | "; | 425 | "; |
424 | $this->update($sql); | 426 | $this->update($sql); |
427 | |||
428 | $sql=" | ||
429 | SELECT COUNT(*) AS count | ||
430 | FROM tblComment | ||
431 | WHERE commentGroup='{$childGroup}' AND gOrder='{$childOrder}'+1; | ||
432 | "; | ||
433 | $count=$this->getValue($sql, "count"); | ||
434 | |||
435 | if($count != 1){ | ||
436 | $sql=" | ||
437 | UPDATE tblComment | ||
438 | SET gOrder=gOrder+1 | ||
439 | WHERE commentNo='{$currentNo}' | ||
440 | "; | ||
441 | $this->update($sql); | ||
442 | } | ||
443 | |||
425 | return $this->makeResultJson("1", "저장되었습니다"); | 444 | return $this->makeResultJson("1", "저장되었습니다"); |
426 | } | 445 | } |
427 | else{ //부모에게 자식이 없을 때 | 446 | else{ //부모에게 자식이 없을 때 |
428 | echo "no child"; | ||
429 | $sql=" | 447 | $sql=" |
430 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) | 448 | INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate) |
431 | VALUES | 449 | VALUES |
... | @@ -459,10 +477,7 @@ if (! class_exists("ApiBoard")) | ... | @@ -459,10 +477,7 @@ if (! class_exists("ApiBoard")) |
459 | $this->update($sql); | 477 | $this->update($sql); |
460 | return $this->makeResultJson("1", "저장되었습니다"); | 478 | return $this->makeResultJson("1", "저장되었습니다"); |
461 | } | 479 | } |
462 | |||
463 | } | 480 | } |
464 | |||
465 | |||
466 | } | 481 | } |
467 | 482 | ||
468 | //제작사양서 저장 | 483 | //제작사양서 저장 | ... | ... |
... | @@ -61,8 +61,8 @@ $(document).ready(function(){ | ... | @@ -61,8 +61,8 @@ $(document).ready(function(){ |
61 | "commentType" : "FB", | 61 | "commentType" : "FB", |
62 | "targetFk" : 1, | 62 | "targetFk" : 1, |
63 | "userFk" : 1, | 63 | "userFk" : 1, |
64 | "content" : "37의 대대댓글", | 64 | "content" : "세 번째 부모" |
65 | "parentNo" : 37 | 65 | |
66 | }, | 66 | }, |
67 | success : function(data){ | 67 | success : function(data){ |
68 | alert(data.returnmessage); | 68 | alert(data.returnmessage); | ... | ... |
-
Please register or sign in to post a comment