Search code examples
mysqlfql.multiquery

Is there a way to combine SQL with FQL (Facebook Query Language)


Is there a way to combine SQL with FQL. I am talking about something like FQL multiqueries.

This is my sample code.

//Here I take data from a SQL database

$result_user_pages = mysql_query("SELECT Page_ID FROM user_fanpage WHERE User_ID='$uid'");

while($row = mysql_fetch_array($result_user_pages))
{
     $user_page_ID[$m]    = $row['Page_ID'] ;
     $m++;
}

//Here I pass '$user_page_ID' array into a for loop and call facebook api

for ($i=0; $i $query1 = "SELECT post_id FROM stream WHERE source_id='$user_page_ID[$i]'"; $query2 = "SELECT fromid,text from comment WHERE post_id IN (SELECT post_id FROM #query1)";

    $queries        =   '{
                           "query1": "' . $query1 . '",
                           "query2": "' . $query2 . '"
                         }';
    $attachment = array("method"=>"fql.multiquery","queries"=>$queries,'access_token'=>$access_token);
    $ret_code = $facebook->api($attachment); 

}

If '$user_page_ID' has 10 elements, api is called 10 times.Therefore sometime it gives me a connection time out error message.If there is a away to combine sql query with fql(like fql multiqueries), I can avoid this error message. Can any one tell me whether there is a way to do this or any other solution...??


Solution

  • You cannot do that with the restrictions that are in place