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

From Organic Design wiki
(get names of users who have edited a particular page)
 
(php db syntax)
Line 2: Line 2:
 
<pre>
 
<pre>
 
select distinct user_name from user,revision where user.user_id = revision.rev_user and revision.rev_page = 5000;
 
select distinct user_name from user,revision where user.user_id = revision.rev_user and revision.rev_page = 5000;
 +
</pre>
 +
 +
==Parser function==
 +
In this context we obtain the ''title_id'' in this way:
 +
<pre>
 +
$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->select($cl,'cl_from',"cl_to = '$category'",__METHOD__,array('ORDER BY' => 'cl_sortkey'));
 +
 +
while ($row = $dbr->fetchRow($res)) $list[] = $row[0];
 +
print_r($list);
 
</pre>
 
</pre>

Revision as of 03:42, 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->select($cl,'cl_from',"cl_to = '$category'",__METHOD__,array('ORDER BY' => 'cl_sortkey'));

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