get.php 1.7 KB

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