doujia1988 2011-06-01 03:59
浏览 32
已采纳

在单个查询中组合3个FQL - Facebook PHP

current i'm doing this FQL to get user info
Please help me combing all the query into one [i want to get all the info in 4 arrays by writing a single FQL] !

$pics=array();
$ids=array();
$names=array();
$sexs=array();
$i=0;

$fql = "SELECT uid FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ";
$fUIDS = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
foreach($fUIDS as $data)
{
 $ids[$i]=$data['uid'];
 $i++;
}
?>
<?php
$fql = "SELECT name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())     ";
$fNames = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
$i=0;
foreach($fNames as $data)
{
 $names[$i]=$data['name'];
 $i++;
}

$fql = "SELECT pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ";
$fPics = $facebook->api(array(
'method' => 'fql.query',
'query' =>$fql,
));
$i=0;
foreach($fPics as $data)
{
 $pics[$i]=$data['pic_square'];
 $i++;
}

$fql = "SELECT sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())";
$fSexs = $facebook->api(array(
    'method' => 'fql.query',
    'query' =>$fql,
    ));
    $i=0;
    foreach($fSexs as $data)
    {
     $sexs[$i]=$data['sex'];
     $i++;
    }
?>
  • 写回答

2条回答 默认 最新

  • doutan1857 2011-06-01 04:04
    关注

    Without any particular knowledge of FQL, I would hazard this guess; it seems to be SQL and you can normally just specify more than one field at a time...

    $pics  = array();
    $ids   = array();
    $names = array();
    $sexs  = array();
    
    $fql   = 'SELECT uid, name, pic_square, sex FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())';
    $data  = $facebook->api(array('method' => 'fql.query','query' => $fql));
    foreach ($data as $datum) {
        $pics[]  = $datum['pic_square'];
        $ids[]   = $datum['uid'];
        $names[] = $datum['name'];
        $sexs[]  = $datum['sex'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器