collect_get.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. //查询term字典
  3. require_once "../path.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../public/function.php';
  6. require_once '../ucenter/function.php';
  7. if(isset($_GET["id"])){
  8. PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
  9. $id=$_GET["id"];
  10. $query = "select * from collect where id = ? ";
  11. $Fetch = PDO_FetchRow($query,array($id));
  12. if($Fetch){
  13. $userinfo = new UserInfo();
  14. $user = $userinfo->getName($Fetch["owner"]);
  15. $Fetch["username"] = $user;
  16. echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
  17. exit;
  18. }
  19. }
  20. else if(isset($_GET["article"])){
  21. # 给文章编号,查文集信息
  22. PDO_Connect("sqlite:"._FILE_DB_USER_ARTICLE_);
  23. $article=$_GET["article"];
  24. $query = "SELECT collect_id FROM article_list WHERE article_id = ? ";
  25. $Fetch = PDO_FetchAll($query,array($article));
  26. /* 使用一个数组的值执行一条含有 IN 子句的预处理语句 */
  27. $params = array();
  28. foreach ($Fetch as $key => $value) {
  29. # code...
  30. $params[] = $value["collect_id"];
  31. }
  32. /* 创建一个填充了和params相同数量占位符的字符串 */
  33. $place_holders = implode(',', array_fill(0, count($params), '?'));
  34. $query = "SELECT * FROM collect WHERE id IN ($place_holders)";
  35. $Fetch = PDO_FetchAll($query,$params);
  36. echo json_encode($Fetch, JSON_UNESCAPED_UNICODE);
  37. exit;
  38. }
  39. echo json_encode(array(), JSON_UNESCAPED_UNICODE);
  40. ?>