本文整理汇总了PHP中Revision::newFromConds方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::newFromConds方法的具体用法?PHP Revision::newFromConds怎么用?PHP Revision::newFromConds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::newFromConds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newFromTitle
/**
* Load either the current, or a specified, revision
* that's attached to a given title. If not attached
* to that title, will return null.
*
* @param Title $title
* @param int $id
* @return Revision
* @access public
* @static
*/
static function newFromTitle(&$title, $id = 0)
{
if ($id) {
$matchId = intval($id);
} else {
$matchId = 'page_latest';
}
return Revision::newFromConds(array("rev_id={$matchId}", 'page_id=rev_page', 'page_namespace' => $title->getNamespace(), 'page_title' => $title->getDbkey()));
}
示例2: newFromTitle
/**
* Load either the current, or a specified, revision
* that's attached to a given title. If not attached
* to that title, will return null.
*
* @param Title $title
* @param int $id
* @return Revision
*/
public static function newFromTitle($title, $id = 0)
{
$conds = array('page_namespace' => $title->getNamespace(), 'page_title' => $title->getDBkey());
if ($id) {
// Use the specified ID
$conds['rev_id'] = $id;
} elseif (wfGetLB()->getServerCount() > 1) {
// Get the latest revision ID from the master
$dbw = wfGetDB(DB_MASTER);
$latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
$conds['rev_id'] = $latest;
} else {
// Use a join to get the latest revision
$conds[] = 'rev_id=page_latest';
}
$conds[] = 'page_id=rev_page';
return Revision::newFromConds($conds);
}
示例3: newFromPageId
/**
* Load either the current, or a specified, revision
* that's attached to a given page ID.
* Returns null if no such revision can be found.
*
* @param $revId Integer
* @param $pageId Integer (optional)
* @return Revision or null
*/
public static function newFromPageId($pageId, $revId = 0)
{
$conds = array('page_id' => $pageId);
if ($revId) {
$conds['rev_id'] = $revId;
} elseif (wfGetLB()->getServerCount() > 1) {
// Get the latest revision ID from the master
$dbw = wfGetDB(DB_MASTER);
$latest = $dbw->selectField('page', 'page_latest', $conds, __METHOD__);
if ($latest === false) {
return null;
// page does not exist
}
$conds['rev_id'] = $latest;
} else {
$conds[] = 'rev_id = page_latest';
}
return Revision::newFromConds($conds);
}