本文整理匯總了PHP中Draft::cleanDrafts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Draft::cleanDrafts方法的具體用法?PHP Draft::cleanDrafts怎麽用?PHP Draft::cleanDrafts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Draft
的用法示例。
在下文中一共展示了Draft::cleanDrafts方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getDrafts
public static function getDrafts($title = null, $userID = null)
{
global $wgUser;
Draft::cleanDrafts();
// Get db connection
$dbw = wfGetDB(DB_MASTER);
// Build where clause
$where = array();
if ($title !== null) {
$pageId = $title->getArticleId();
if ($pageId) {
$where['draft_page'] = $pageId;
} else {
$where['draft_page'] = 0;
// page not created yet
$where['draft_namespace'] = $title->getNamespace();
$where['draft_title'] = $title->getDBKey();
}
}
if ($userID !== null) {
$where['draft_user'] = $userID;
} else {
$where['draft_user'] = $wgUser->getID();
}
// Create an array of matching drafts
$drafts = array();
$result = $dbw->select('drafts', '*', $where, __METHOD__);
if ($result) {
while ($row = $dbw->fetchRow($result)) {
// Add a new draft to the list from the row
$drafts[] = Draft::newFromRow($row);
}
}
// Return array of matching drafts
return count($drafts) ? $drafts : null;
}