get_split_data.php 915 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. require_once '../path.php';
  3. require_once '../redis/function.php';
  4. require_once '../dict/function.php';
  5. $output=json_encode(array(), JSON_UNESCAPED_UNICODE);
  6. if(isset($_GET["word"])){
  7. $inputWord = $_GET["word"];
  8. }
  9. else{
  10. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  11. exit;
  12. }
  13. $redis = redis_connect();
  14. if($redis!==false){
  15. #如果没有查巴缅替换拆分
  16. if($redis->hExists("dict://comp",$inputWord)===TRUE){
  17. $output = $redis->hGet("dict://comp",$inputWord) ;
  18. echo $output;
  19. exit;
  20. }
  21. }
  22. else{
  23. $dbh = new PDO(_DICT_DB_COMP_, "", "", array(PDO::ATTR_PERSISTENT => true));
  24. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  25. $query = "SELECT parts from "._TABLE_DICT_COMP_." where pali =?";
  26. $stmt = $dbh->prepare($query);
  27. $stmt->execute(array($inputWord));
  28. $fComp = $stmt->fetchAll(PDO::FETCH_ASSOC);
  29. $output = json_encode($fComp, JSON_UNESCAPED_UNICODE);
  30. echo $output;
  31. }
  32. ?>