本文整理汇总了PHP中LinkCache::addLink方法的典型用法代码示例。如果您正苦于以下问题:PHP LinkCache::addLink方法的具体用法?PHP LinkCache::addLink怎么用?PHP LinkCache::addLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LinkCache
的用法示例。
在下文中一共展示了LinkCache::addLink方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: watchlist
$sql = "DROP TABLE IF EXISTS watchlist";
wfQuery($sql, DB_MASTER);
$sql = "CREATE TABLE watchlist (\n wl_user int(5) unsigned NOT NULL,\n wl_page int(8) unsigned NOT NULL,\n UNIQUE KEY (wl_user, wl_page)\n) ENGINE=MyISAM PACK_KEYS=1";
wfQuery($sql, DB_MASTER);
$lc = new LinkCache();
# Now, convert!
$sql = "SELECT user_id,user_watch FROM user";
$res = wfQuery($sql, DB_SLAVE);
$nu = wfNumRows($res);
$sql = "INSERT into watchlist (wl_user,wl_page) VALUES ";
$i = $n = 0;
while ($row = wfFetchObject($res)) {
$list = explode("\n", $row->user_watch);
$bits = array();
foreach ($list as $title) {
if ($id = $lc->addLink($title) and !$bits[$id]++) {
$sql .= ($i++ ? "," : "") . "({$row->user_id},{$id})";
}
}
if ($n++ % 100 == 0) {
echo "{$n} of {$nu} users done...\n";
}
}
echo "{$n} users done.\n";
if ($i) {
wfQuery($sql, DB_MASTER);
}
# Add index
# is this necessary?
$sql = "ALTER TABLE watchlist\n ADD INDEX wl_user (wl_user),\n ADD INDEX wl_page (wl_page)";
#wfQuery( $sql, DB_MASTER );