[Mediawiki-l] DB query: Articles of a given Category
Vernon Thommeret
synotic at gmail.com
Wed Feb 21 22:30:21 UTC 2007
Hi,
I'm trying to come up with code that can tell me whether or not a
given category has articles or not. Naturally, I borrowed some code
from CategoryPage.php. This is what I got up to:
$res2 = $dbr->select(
array( 'page', 'categorylinks' ),
array( 'page_title' ),
array( 'cl_from = page_id', 'cl_to' => $title->getArticleID()),
$fname,
array('LIMIT' => 1 ));
echo $res2;
echo $dbr->fetchObject($res2);
The "echo $res2" spouts off a "Resource #12" or whatever, but the
second echo doesn't leave anything.
Now, my knowledge of MySQL is limited, and my knowledge of how it
works in MediaWiki is even worse, so bear with me. I realize this is
largely completely wrong. Am I on the right track at all?
For some context, I'm in the "replaceLinkHolders" function in
Parser.php. This is where it goes through the links and decides
whether to make them active or not. Basically, I just need to know if
a category (represented by $title = $this->mLinkHolders['titles']
[$key];) has any articles, which I can determine by performing a
database query. I'm just having trouble figuring out how to get some
kind of result at all. If I can do at least that, I can fill in the
rest.
Help?
More information about the MediaWiki-l
mailing list