Difference between revisions of "Extension talk:Friends.php"

From Organic Design wiki
(php db syntax)
m
Line 8: Line 8:
 
<pre>
 
<pre>
 
$id = $wgTitle->getArticleID();
 
$id = $wgTitle->getArticleID();
 
  
 
$dbr  = &wfGetDB(DB_SLAVE);
 
$dbr  = &wfGetDB(DB_SLAVE);
Line 15: Line 14:
  
 
$sql = "select distinct user_name from $u,$r where $u.user_id = $r.rev_user and $r.rev_page = $id;";
 
$sql = "select distinct user_name from $u,$r where $u.user_id = $r.rev_user and $r.rev_page = $id;";
 
+
$res  = $dbr->query($sql);
#$res  = $dbr->select($cl,'cl_from',"cl_to = '$category'",__METHOD__,array('ORDER BY' => 'cl_sortkey'));
 
  
 
while ($row = $dbr->fetchRow($res)) $list[] = $row[0];
 
while ($row = $dbr->fetchRow($res)) $list[] = $row[0];
 
print_r($list);
 
print_r($list);
 
</pre>
 
</pre>

Revision as of 03:43, 25 March 2008

sql query (to get names of users who have edited a particular page):

select distinct user_name from user,revision where user.user_id = revision.rev_user and revision.rev_page = 5000;

Parser function

In this context we obtain the title_id in this way:

$id = $wgTitle->getArticleID();

$dbr  = &wfGetDB(DB_SLAVE);
$u = $dbr->tableName('user');
$r = $dbr->tableName('revision');

$sql = "select distinct user_name from $u,$r where $u.user_id = $r.rev_user and $r.rev_page = $id;";
$res  = $dbr->query($sql);

while ($row = $dbr->fetchRow($res)) $list[] = $row[0];
print_r($list);