get_sim.php 771 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /*
  3. get user sentence from db
  4. */
  5. require_once "../path.php";
  6. require_once "../public/_pdo.php";
  7. require_once "../public/function.php";
  8. $sim = $_POST["sim"];
  9. $simList = json_decode($sim);
  10. $output = array();
  11. $dns = "sqlite:"._FILE_DB_PALI_SENTENCE_;
  12. $dbh = new PDO($dns, "", "",array(PDO::ATTR_PERSISTENT=>true));
  13. $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  14. $query="SELECT * FROM pali_sent WHERE id = ? ";
  15. $stmt = $dbh->prepare($query);
  16. foreach ($simList as $value) {
  17. # code...
  18. $stmt->execute(array($value));
  19. $Fetch = $stmt->fetch(PDO::FETCH_ASSOC);
  20. if($Fetch){
  21. $sent = $Fetch;
  22. $sent["path"]=_get_para_path($Fetch["book"],$Fetch["paragraph"]);
  23. $output[] = $sent;
  24. }
  25. }
  26. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  27. ?>