get.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. //
  3. require_once "../path.php";
  4. require_once "../public/_pdo.php";
  5. require_once '../ucenter/function.php';
  6. $_userinfo = new UserInfo();
  7. PDO_Connect("sqlite:"._FILE_DB_CHANNAL_);
  8. $query = "SELECT * from channal where owner = ? limit 0,100";
  9. $Fetch_my = PDO_FetchAll($query,array($_COOKIE["userid"]));
  10. # 找协作的
  11. $Fetch_coop = array();
  12. $query = "SELECT channal_id FROM cooperation WHERE user_id = ? ";
  13. $coop_channal = PDO_FetchAll($query,array($_COOKIE["userid"]));
  14. if(count($coop_channal)>0){
  15. foreach ($coop_channal as $key => $value) {
  16. # code...
  17. $channal[]=$value["channal_id"];
  18. }
  19. /* 创建一个填充了和params相同数量占位符的字符串 */
  20. $place_holders = implode(',', array_fill(0, count($channal), '?'));
  21. $query = "SELECT * FROM channal WHERE id IN ($place_holders) order by owner";
  22. $Fetch_coop = PDO_FetchAll($query,$channal);
  23. }
  24. $all = array_merge_recursive($Fetch_my,$Fetch_coop);
  25. $output = array();
  26. foreach ($all as $key => $value) {
  27. # code...
  28. $new = $value;
  29. $name = $_userinfo->getName($value["owner"]);
  30. $new["username"] = $name["username"];
  31. $new["nickname"] = $name["nickname"];
  32. $new["count"] = 0;
  33. $new["all"] = 1;
  34. $output[]=$new;
  35. }
  36. echo json_encode($output, JSON_UNESCAPED_UNICODE);
  37. ?>