list_article_in_collect.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. //查询某article 在哪几个collection里面出现
  3. require_once "../config.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../public/function.php';
  6. require_once '../ucenter/function.php';
  7. $output = array();
  8. if(isset($_GET["id"])){
  9. PDO_Connect(_FILE_DB_USER_ARTICLE_,_DB_USERNAME_,_DB_PASSWORD_);
  10. $article_id=$_GET["id"];
  11. $query = "SELECT collect_id as id from "._TABLE_ARTICLE_COLLECTION_." where article_id = ? ";
  12. $exist = PDO_FetchAll($query,array($article_id));
  13. $exist_id = array();
  14. #查询已经存在的collection详细信息
  15. for ($i=0; $i < count($exist) ; $i++) {
  16. # query collect title
  17. $query = "SELECT title from "._TABLE_COLLECTION_." where uid = ? ";
  18. $exist[$i]["title"] = PDO_FetchOne($query,array($exist[$i]["id"]));
  19. $exist_id[$exist[$i]["id"]] = 1;
  20. }
  21. $output["exist"] = $exist;
  22. #查询所有的
  23. $query = "SELECT uid as id,title from "._TABLE_COLLECTION_." where owner = ? AND status <> 0 order by modify_time DESC limit 50";
  24. $others = PDO_FetchAll($query,array($_COOKIE["user_uid"]));
  25. foreach ($others as $key => $value) {
  26. # remove exist record
  27. if(!isset($exist_id[$value["id"]])){
  28. $output["others"][] = $value;
  29. }
  30. }
  31. $output["article_id"]=$article_id;
  32. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  33. }
  34. else{
  35. echo json_encode(array(), JSON_UNESCAPED_UNICODE);
  36. }
  37. ?>