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


PHP Contest::writeAllToDB方法代码示例

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


在下文中一共展示了Contest::writeAllToDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onSubmit

 /**
  * Process the form.  At this point we know that the user passes all the criteria in
  * userCanExecute(), and if the data array contains 'Username', etc, then Username
  * resets are allowed.
  *
  * @param array $data
  *
  * @return Bool|Array
  */
 public function onSubmit(array $data)
 {
     $fields = array();
     foreach ($data as $name => $value) {
         $matches = array();
         if (preg_match('/contest-(.+)/', $name, $matches)) {
             if ($matches[1] == 'end') {
                 $value = wfTimestamp(TS_MW, strtotime($value));
             }
             $fields[$matches[1]] = $value;
         }
     }
     // If no ID is set, this means it's a new contest, so set the ID to null for an insert.
     // However, the user can have hot the back button after creation of a new contest,
     // re-submitting the form. In this case, get the ID of the already existing item for an update.
     if (!array_key_exists('id', $fields) || $fields['id'] === '') {
         $contest = Contest::s()->selectRow('id', array('name' => $fields['name']));
         $fields['id'] = $contest === false ? null : $contest->getField('id');
     }
     $contest = new Contest($fields, is_null($fields['id']));
     $contest->setChallenges($this->getSubmittedChallenges());
     $success = $contest->writeAllToDB();
     $success = $this->removeDeletedChallenges($data['delete-challenges']) && $success;
     if ($success) {
         return true;
     } else {
         return array();
         // TODO
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:39,代码来源:SpecialEditContest.php


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