I'm still working a little blind, I don't have enough detailed
information and context on what exactly you're trying to do to give the
best suggestion.
I don't know if this is exactly what is wanted since I don't have data
to test it on. And I'm not sure atm if a JOIN, LEFT JOIN, or RIGHT JOIN
is best.
$res = $db->select(
array( 'categorylinks', 'imagelinks', 'page' ),
array( 'page_id', 'cl_to', 'COUNT(cl_to) as cl_count' ),
array(
'page_id' => $pidsArray,
'page_namespace' => NS_FILE,
),
__METHOD__,
array( 'GROUP BY' => 'cl_to' ),
array(
'imagelinks' => array( 'JOIN', 'il_from=cl_from' ),
'page' => array( 'JOIN', 'page_title=il_to' ),
)
);
foreach ( $res as $row ) {
$row->page_id;
$row->cl_to;
$row->cl_count;
// [...]
}
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
On 11-04-14 07:54 AM, Stefan Werthmann wrote:
> Hey! Wow!
>
> yes it's very blaming. Your code looks mutch more better!
>
> The $e was just for convenience.
>
> Actually I need something like this as end result:
>
> for($i=1;$i<count($pidsArray);$i++):
> $qString = "SELECT cl_to,count(*) as cl_count from
> ".$wgDBprefix."categorylinks where cl_from='".$pidsArray[$i]."' group by
> cl_to having cl_count >0";
> $wgRes = $db->query($qString);
> while($row = $db->fetchObject($wgRes)):
> $categories[$i]['cl_to']=$row->cl_to;
> $categories[$i]['cl_count']=$row->cl_count;
> endwhile;
> endfor;
>
> Is there a way to modify your code in this direction?
_______________________________________________
MediaWiki-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l