fork download
  1. <?php
  2.  
  3. class CommentDataGateway {
  4.  
  5. public function getNumber($properties, $commentParentID)
  6. {
  7. if (!empty($commentParentID)) {
  8. $query = "SELECT COUNT(*) + 1
  9. FROM comments
  10. WHERE fileID = :fileID AND
  11. path LIKE CONCAT(
  12. (SELECT path
  13. FROM comments
  14. WHERE commentID = :commentParentID), '.%')";
  15. } else {
  16. $query = "SELECT COUNT(*) + 1
  17. FROM comments
  18. WHERE fileID = :fileID AND
  19. CHAR_LENGTH (path) = 3";
  20. }
  21. $stmt = $this->pdo->prepare($query);
  22. $stmt->bindValue(":fileID", $properties["fileID"], \PDO::PARAM_STR);
  23. if (!empty($commentParentID)) {
  24. $stmt->bindValue(":commentParentID", $commentParentID, \PDO::PARAM_INT);
  25. }
  26. $stmt->execute();
  27. $number = $stmt->fetchColumn();
  28. return $number;
  29. }
  30.  
  31. public function getPath($properties, $commentParentID)
  32. {
  33. $query = "SELECT CONCAT(path, '.00', :number)
  34. FROM comments
  35. WHERE fileID = :fileID
  36. AND commentID = :commentParentID";
  37. $stmt = $this->pdo->prepare($query);
  38. $stmt->bindValue(":number", $properties["number"], \PDO::PARAM_INT);
  39. $stmt->bindValue(":fileID", $properties["fileID"], \PDO::PARAM_STR);
  40. $stmt->bindValue(":commentParentID", $commentParentID, \PDO::PARAM_INT);
  41. $stmt->execute();
  42. $path = $stmt->fetchColumn();
  43. return $path;
  44. }
  45. }
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
Standard output is empty