1

I've got my 3 queries all set up in my connection and configuration to Facebook. The configuration is correct as I'm getting return values. Here is my queries:

$fql_friends_fan_pages = array(
    'query1' => "SELECT uid2 FROM friend WHERE uid1 = me()", //get all me()'s friends
    'query2' => "SELECT page_id FROM page_fan WHERE uid IN (SELECT uid2 FROM #query1)", //get all fan page references from friends
    'query3' => "SELECT name FROM page WHERE page_id IN (SELECT page_id FROM #query2)" //get all info from friends' fan pages
);

What I'm getting returned is the product of the 2nd query and not the 3rd; it seems to totally ignore it. I'm trying to get the information for all of my friends' pages. Instead of retrieving all the names, it prints out the page_id's for each page (from query2). Any idea why it's ignoring the 3rd query?

EDIT:

I've managed to get it working by merging the first and second query together into one larger query. Is there a known limit of 2 queries in FQL multiqueries?

$fql_friends_fan_pages = array(
    'query1' => "SELECT uid2 FROM friend WHERE uid1 = me()", //get all me()'s friends
    'query2' => "SELECT page_id FROM page_fan WHERE uid IN (SELECT uid2 FROM #query1)", //get all fan page references from friends
    'query3' => "SELECT name FROM page WHERE page_id IN (SELECT page_id FROM #query2)" //get all info from friends' fan pages
);
$params_friends_fan_pages = array(
    'method' => 'fql.multiquery',
    'queries' => $fql_friends_fan_pages
);
$friends_fan_pages = $facebook->api($params_friends_fan_pages);
Prusprus
  • 7,987
  • 9
  • 42
  • 57
  • I don't see any issue with your queries. You should be getting data for all three of them. If there is a limit on multiqueries with the PHP SDK, it's higher than 7. I've run that many before for a complex data scrape. – cpilko Jul 20 '12 at 01:30
  • Another odd thing i've noticed - usually when i submit multiqueries (2 queries in my case), i expect to get returned an array with the result of both queries. From there I just grab the last array since this is the resultset for the last query. In the case of the above query, I only get one array returned; no resultset for the first query. The resultset is fairly big (4000+ items), so I wonder if the size of the result set may affect what resultset is returned? I've tried setting a limit on query 2 (of 50) but that doesn't seem to help, maybe I'm missing something? – Prusprus Jul 20 '12 at 14:00
  • With a multiquery, you should get a big array where the results of each query are there in sub arrays. Can you post the code of your full `api` call plus your result handler? – cpilko Jul 20 '12 at 14:38
  • 1
    BTW, if you aren't planning to use results from your `query1` or `query2`, you should use a single nested query rather than a multiquery. The performance is faster. – cpilko Jul 20 '12 at 14:39
  • Good point about the nested queries. I thought that the possibility of defining separate queries was to help maintainability and code comprehension. – Prusprus Jul 20 '12 at 15:25
  • No. The point of a multiquery is to allow you to get data from multiple tables in a single API call. – cpilko Jul 20 '12 at 19:55
  • When I run this code I see all three result sets when I `print_r($friends_fan_pages)` – cpilko Jul 20 '12 at 20:05

0 Answers0