当前位置: 首页>>代码示例>>PHP>>正文


PHP Draft::newFromRow方法代码示例

本文整理汇总了PHP中Draft::newFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP Draft::newFromRow方法的具体用法?PHP Draft::newFromRow怎么用?PHP Draft::newFromRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Draft的用法示例。


在下文中一共展示了Draft::newFromRow方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:36,代码来源:Drafts.classes.php

示例2: get

 /**
  * Gets a list of existing drafts for a specific user
  *
  * @param $title Object: [optional] Title of article, defaults to all articles
  * @param $userID Integer: [optional] ID of user, defaults to current user
  * @return List of drafts or null
  */
 public static function get($title = null, $userID = null)
 {
     global $wgUser;
     // Removes expired drafts for a more accurate list
     Drafts::clean();
     // Gets database connection
     $dbw = wfGetDB(DB_MASTER);
     // Builds where clause
     $where = array('draft_savetime > ' . $dbw->addQuotes($dbw->timestamp(self::getDraftAgeCutoff())));
     // Checks if specific title was given
     if ($title !== null) {
         // Get page id from title
         $pageId = $title->getArticleId();
         // Checks if page id exists
         if ($pageId) {
             // Adds specific page id to conditions
             $where['draft_page'] = $pageId;
         } else {
             // Adds new page information to conditions
             $where['draft_namespace'] = $title->getNamespace();
             $where['draft_title'] = $title->getDBkey();
         }
     }
     // Checks if a specific user was given
     if ($userID !== null) {
         // Adds specific user to conditions
         $where['draft_user'] = $userID;
     } else {
         // Adds current user to conditions
         $where['draft_user'] = $wgUser->getID();
     }
     // Gets matching drafts from database
     $result = $dbw->select('drafts', '*', $where, __METHOD__);
     if ($result) {
         // Creates an array of matching drafts
         $drafts = array();
         while ($row = $dbw->fetchRow($result)) {
             // Adds a new draft to the list from the row
             $drafts[] = Draft::newFromRow($row);
         }
     }
     // Returns array of matching drafts or null if there were none
     return count($drafts) ? $drafts : null;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:51,代码来源:Drafts.classes.php


注:本文中的Draft::newFromRow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。