[Mediawiki-l] Database handler help

Christensen, Courtney ChristensenC at BATTELLE.ORG
Mon Sep 17 19:50:15 UTC 2007


I'm trying to do two queries, does this code look right?
bchocitation is a table that holds information about citations we are
using.  Ultimately I want a list of all citations that are not linked
to.  My plan was to get the list of citation titles, and compare them
against titles in pagelinks, if the title does not appear in pagelinks
then it isn't linked to.


//SELECT page_title FROM bchocitation, page WHERE
bchocitation.page_id=page.page_id;
$results = array();
$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select(
	    array( 'bchocitation', 'page'), //from
	    'page_title',		  //select
	    array('bchocitation.page_id'=>'page.page_id'),//where
	    __METHOD__,
	    array() //extras
	);
while ($obj = $dbr->fetchObject($res)) {
	    $results[] = $obj;
} 
$dbr->freeResult($res);
	
	
//SELECT pl_title FROM pagelinks WHERE pl_title='$title';
$result = "";
$dbr =& wfGetDB( DB_SLAVE );
$res = $dbr->select(
    'pagelinks', //from
    'pl_title',		  //select
    array('pl_title'=>"'$title'"),//where
    __METHOD__,
    array() //extras
);
while ($obj = $dbr->fetchObject($res)) {
    $result = $obj; 
} 
$dbr->freeResult($res);



Any help is much appreciated!
-Courtney Christensen



More information about the MediaWiki-l mailing list