With the following code I get all the pages I admin on Facebook using FQL. I do not print them though.
$PageNames = $facebook->api('/fql', array('q' =>
'SELECT name, page_id FROM page WHERE page_id IN (
SELECT page_id FROM page_admin WHERE uid=me() )'));
Previously, I have added in my DB the *page_id* of some of my pages. My goal is to show the pages that I have not added to my DB yet. It is working correctly and the code is below.
foreach($PageNames['data'] as $PageName) {
$investigate_id = mysql_query("SELECT page_id FROM pages WHERE page_id='"
.$PageName['page_id']."' LIMIT 1 ");
if(mysql_num_rows($investigate_id) == 0) {
echo $PageName['page_id'].$PageName['name'];
}
}
My problem/question is if somehow I can avoid the numerous DB calls because it makes the query for every page I admin. How can I achieve this?
You may collect the IDs from results you got with FQL and then query DB for rows that exists in results to filter those present in DB from results…