Hi all!
Could someone translate this to a single sophisticated mysql-statement
(perhaps with a count() on the categories-result)?
The code below retrieves category links from pages (articles) containing
specific files.
At the beginning I only have page ids from the filepages.
for($i=1;$i<count($pidsArray);$i++):
$qString = "SELECT page_title FROM ".$wgDBprefix."page where
page_id='".$pidsArray[$i]."' and page_namespace=6";/* File:
namespace */
$wgRes = $db->query($qString);
while($row = $db->fetchObject($wgRes)):
$imagePages[$i]=$row->page_title;
endwhile;
endfor;
$e=0;
for($i=1;$i < count($imagePages);$i++):
$qString = "SELECT il_from FROM ".$wgDBprefix."imagelinks
where
il_to='".$imagePages[$i]."'";/* File: namespace */
$wgRes = $db->query($qString);
$row = $db->fetchObject($wgRes);
while($row = $db->fetchObject($wgRes)):
$imageLinks[$e]=$row->il_from;
endwhile;
endfor;
for($i=0;$i<count($imageLinks);$i++):
$qString = "SELECT cl_to FROM ".$wgDBprefix."categorylinks
where
cl_from='".$imageLinks[$i]."'";
$wgRes = $db->query($qString);
while($row = $db->fetchObject($wgRes)):
$categories[$i]=$row->cl_to;
endwhile;
endfor;
c u stevie