pali_text.php 1.3 KB

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