2
0

pali_text.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. require_once "../path.php";
  3. require_once "../db/table.php";
  4. class PaliText extends Table
  5. {
  6. function __construct($redis=false) {
  7. parent::__construct(_FILE_DB_PALITEXT_, "pali_text", "", "",$redis);
  8. }
  9. public function getTitle($book,$para)
  10. {
  11. if (isset($book) && isset($para)) {
  12. if($this->redis!==false){
  13. $title = $this->redis->hGet("para_title://pali","{$book}-{$para}");
  14. if($title!==FALSE){
  15. return $title;
  16. }
  17. }
  18. $title="";
  19. $query = "select * from pali_text where book = ? and paragraph = ?";
  20. $stmt = $this->dbh->prepare($query);
  21. $stmt->execute(array($book,$para));
  22. $result = $stmt->fetch(PDO::FETCH_ASSOC);
  23. if ($result) {
  24. if($result["level"]>0 && $result["level"]<8){
  25. $title= $result["toc"];
  26. }
  27. else{
  28. $query = "select * from pali_text where book = ? and paragraph = ?";
  29. $stmt = $this->dbh->prepare($query);
  30. $stmt->execute(array($book,$result["parent"]));
  31. $result = $stmt->fetch(PDO::FETCH_ASSOC);
  32. if ($result) {
  33. $title= $result["toc"];
  34. }
  35. else{
  36. $title= "";
  37. }
  38. }
  39. } else {
  40. $title= "";
  41. }
  42. $output = $this->redis->hSet("para_title://pali","{$book}-{$para}",$title);
  43. return $title;
  44. } else {
  45. $title= "";
  46. }
  47. }
  48. }
  49. ?>