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


PHP XenForo_Db::commit方法代码示例

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


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

示例1: execute

 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'batch' => 70), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $userModel XenForo_Model_User */
     $userModel = XenForo_Model::create('XenForo_Model_User');
     /* @var $conversationModel XenForo_Model_Conversation */
     $conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
     $userIds = $userModel->getUserIdsInRange($data['position'], $data['batch']);
     if (sizeof($userIds) == 0) {
         return true;
     }
     foreach ($userIds as $userId) {
         $data['position'] = $userId;
         /* @var $userDw XenForo_DataWriter_User */
         $userDw = XenForo_DataWriter::create('XenForo_DataWriter_User', XenForo_DataWriter::ERROR_SILENT);
         if ($userDw->setExistingData($userId)) {
             XenForo_Db::beginTransaction();
             $userDw->set('alerts_unread', $userModel->getUnreadAlertsCount($userId));
             $userDw->set('conversations_unread', $conversationModel->countUnreadConversationsForUser($userId));
             $userDw->save();
             $userDw->rebuildUserGroupRelations();
             $userDw->rebuildPermissionCombinationId();
             $userDw->rebuildDisplayStyleGroupId();
             $userDw->rebuildCustomFields();
             $userDw->rebuildIgnoreCache();
             XenForo_Db::commit();
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('users');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:34,代码来源:User.php

示例2: uninstall

 public static function uninstall()
 {
     //Get the db
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     //Drop the custom tables from the db
     try {
         $db->query("\n\t\t\t    DROP TABLE IF EXISTS `xf_thread_rating`\n\t\t   ");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_count` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_count`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_sum` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_sum`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     //Drop the `rating_avg` field from the thread table
     try {
         $db->query("\n\t\t\t\tALTER TABLE xf_thread\n\t\t\t\t\tDROP COLUMN `rating_avg`\n\t\t\t");
     } catch (Zend_Db_Exception $e) {
     }
     XenForo_Db::commit($db);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:27,代码来源:Install.php

示例3: rebuild

 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = isset($options['batch']) ? $options['batch'] : 75;
     $options['batch'] = max(1, $options['batch']);
     /* @var $userModel XenForo_Model_User */
     $userModel = XenForo_Model::create('XenForo_Model_User');
     /* @var $conversationModel XenForo_Model_Conversation */
     $conversationModel = XenForo_Model::create('XenForo_Model_Conversation');
     $userIds = $userModel->getUserIdsInRange($position, $options['batch']);
     if (sizeof($userIds) == 0) {
         return true;
     }
     XenForo_Db::beginTransaction();
     foreach ($userIds as $userId) {
         $position = $userId;
         /* @var $userDw XenForo_DataWriter_User */
         $userDw = XenForo_DataWriter::create('XenForo_DataWriter_User', XenForo_DataWriter::ERROR_SILENT);
         if ($userDw->setExistingData($userId)) {
             $userDw->set('alerts_unread', $userModel->getUnreadAlertsCount($userId));
             $userDw->set('conversations_unread', $conversationModel->countUnreadConversationsForUser($userId));
             $userDw->save();
             $userDw->rebuildUserGroupRelations();
             $userDw->rebuildPermissionCombinationId();
             $userDw->rebuildDisplayStyleGroupId();
             $userDw->rebuildIdentities();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:36,代码来源:User.php

示例4: rebuild

 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     if ($position == 0) {
         XenForo_Model::create('XenForo_Model_Node')->updateNestedSetInfo();
     }
     /* @var $forumModel XenForo_Model_Forum */
     $forumModel = XenForo_Model::create('XenForo_Model_Forum');
     $forums = $forumModel->getForums(array(), array('limit' => $options['batch'], 'offset' => $position));
     XenForo_Db::beginTransaction();
     foreach ($forums as $forum) {
         $position++;
         $forumDw = XenForo_DataWriter::create('XenForo_DataWriter_Forum', XenForo_DataWriter::ERROR_SILENT);
         if ($forumDw->setExistingData($forum, true)) {
             $forumDw->rebuildCounters();
             $forumDw->save();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     if (!$forums) {
         return true;
     } else {
         return $position;
     }
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:31,代码来源:Forum.php

示例5: rebuild

 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     $socialForumModel = ThemeHouse_SocialGroups_SocialForum::getSocialForumModel();
     if ($position == 0) {
         $socialForumModel->unlinkMovedThreads();
     }
     $socialForums = $socialForumModel->getSocialForums(array(), array('limit' => $options['batch'], 'offset' => $position));
     XenForo_Db::beginTransaction();
     foreach ($socialForums as $socialForum) {
         $position++;
         /* @var $socialForumDw ThemeHouse_SocialGroups_DataWriter_SocialForum */
         $socialForumDw = XenForo_DataWriter::create('ThemeHouse_SocialGroups_DataWriter_SocialForum', XenForo_DataWriter::ERROR_SILENT);
         if ($socialForumDw->setExistingData($socialForum, true)) {
             $socialForumDw->rebuildCounters();
             $socialForumDw->save();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     if (!$socialForums) {
         return true;
     } else {
         return $position;
     }
 }
开发者ID:AndroidOS,项目名称:SocialGroups,代码行数:31,代码来源:SocialForum.php

示例6: execute

 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('tagId' => null, 'position' => 0, 'deleteFirst' => false), $data);
     if (!$data['tagId']) {
         return false;
     }
     $db = XenForo_Application::getDb();
     $matches = $db->fetchAll("\r\n\t\t\tSELECT tag_content_id, content_type, content_id\r\n\t\t\tFROM xf_tag_content\r\n\t\t\tWHERE tag_id = ?\r\n\t\t\t\tAND tag_content_id > ?\r\n\t\t\tORDER BY tag_content_id\r\n\t\t\tLIMIT 1000\r\n\t\t", array($data['tagId'], $data['position']));
     if (!$matches) {
         return false;
     }
     /** @var XenForo_Model_Tag $tagModel */
     $tagModel = XenForo_Model::create('XenForo_Model_Tag');
     XenForo_Db::beginTransaction($db);
     $limitTime = $targetRunTime > 0;
     $s = microtime(true);
     foreach ($matches as $match) {
         $data['position'] = $match['tag_content_id'];
         if ($data['deleteFirst']) {
             $db->delete('xf_tag_content', 'tag_content_id = ' . $match['tag_content_id']);
         }
         $tagModel->rebuildTagCache($match['content_type'], $match['content_id']);
         if ($limitTime && microtime(true) - $s >= $targetRunTime) {
             break;
         }
     }
     XenForo_Db::commit($db);
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('tags');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:32,代码来源:TagRecache.php

示例7: rebuild

 /**
  * @see XenForo_CacheRebuilder_DailyStats::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = isset($options['batch']) ? $options['batch'] : 28;
     $options['batch'] = max(1, $options['batch']);
     /* @var $userModel XenForo_Model_Stats */
     $statsModel = XenForo_Model::create('XenForo_Model_Stats');
     if ($position == 0) {
         // delete old stats cache if required
         if (!empty($options['delete'])) {
             $statsModel->deleteStats();
         }
         $xenOptions = XenForo_Application::get('options');
         // an appropriate date from which to start... first thread, or earliest user reg?
         if ($xenOptions->th_noForo_noForum) {
             $position = XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate();
         } else {
             $position = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
         }
         // start on a 24 hour increment point
         $position = $position - $position % 86400;
     } else {
         if ($position > XenForo_Application::$time) {
             return true;
         }
     }
     XenForo_Db::beginTransaction();
     $endPosition = $position + $options['batch'] * 86400;
     $data = $statsModel->buildStatsData($position, $endPosition);
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::date($position, 'absolute');
     return $endPosition;
 }
开发者ID:ThemeHouse-XF,项目名称:NoForo,代码行数:35,代码来源:DailyStats.php

示例8: execute

 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     return true;
     $data = array_merge(array('position' => 0, 'batch' => 10), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $feedbackModel NixFifty_XenTrader_Model_Feedback */
     $feedbackModel = XenForo_Model::create('NixFifty_XenTrader_Model_Feedback');
     $feedbackItems = $feedbackModel->getUserIdsInFeedbackRange($data['position'], $data['batch']);
     if (sizeof($feedbackItems) == 0) {
         return true;
     }
     $db = XenForo_Application::getDb();
     XenForo_Db::beginTransaction($db);
     foreach ($feedbackItems as $feedbackItem) {
         $data['position'] = $item['media_id'];
         $feedbackCount = $db->fetchOne('
             SELECT COUNT(*)
             FROM xf_nixfifty_xentrader_feedback
             WHERE to_user_id = ?
         ', $feedbackItem);
         $db->update('xf_nixfifty_xentrader_user', array('total' => $feedbackCount), 'user_id = ' . $db->quote($feedbackItem));
     }
     XenForo_Db::commit($db);
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = 'fam i think im broken';
     //new XenForo_Phrase('xengallery_rebuild_thumbnails');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
开发者ID:melvingb,项目名称:XenForo-XenTrader,代码行数:29,代码来源:FeedbackCount.php

示例9: execute

    public function execute(array $deferred, array $data, $targetRunTime, &$status)
    {
        $data = array_merge(array('position' => 0, 'batch' => 10), $data);
        $data['batch'] = max(1, $data['batch']);
        /* @var $albumModel XenGallery_Model_Album */
        $albumModel = XenForo_Model::create('XenGallery_Model_Album');
        $albumIds = $albumModel->getSharedAlbumIdsInRange($data['position'], $data['batch']);
        if (sizeof($albumIds) == 0) {
            return true;
        }
        $db = XenForo_Application::getDb();
        XenForo_Db::beginTransaction($db);
        foreach ($albumIds as $albumId) {
            $data['position'] = $albumId;
            $album = $albumModel->getAlbumByIdSimple($albumId);
            $bind = array($album['album_id'], $album['album_user_id']);
            $ownerShared = $db->fetchOne('SELECT shared_user_id FROM xengallery_shared_map WHERE album_id = ? AND shared_user_id = ?', $bind);
            if (!$ownerShared) {
                $db->query('
					INSERT IGNORE INTO xengallery_shared_map
						(album_id, shared_user_id)
					VALUES
						(?, ?)
				', $bind);
            }
        }
        XenForo_Db::commit($db);
        $actionPhrase = new XenForo_Phrase('rebuilding');
        $typePhrase = new XenForo_Phrase('xengallery_album_permissions');
        $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
        return $data;
    }
开发者ID:VoDongMy,项目名称:xenforo-laravel5.1,代码行数:32,代码来源:901000570.php

示例10: rebuild

 /**
  * @param int $position
  * @param array $options
  * @param string $detailedMessage
  * @return bool|int|string|true
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = max(1, isset($options['batch']) ? $options['batch'] : 10);
     /* @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     $locations = $locationModel->getLocationsWithoutCoordinate($position, $options['batch']);
     if (count($locations) < 1) {
         return true;
     }
     XenForo_Db::beginTransaction();
     $db = XenForo_Application::getDb();
     /** @var sonnb_XenGallery_Model_Location $locationModel */
     $locationModel = XenForo_Model::create('sonnb_XenGallery_Model_Location');
     foreach ($locations as $locationId => $location) {
         $position = $location['location_id'];
         try {
             $client = XenForo_Helper_Http::getClient($locationModel->getGeocodeUrlForAddress($location['location_name']));
             $response = $client->request('GET');
             $response = @json_decode($response->getBody(), true);
             if (empty($response['results'][0])) {
                 continue;
             }
             $address = $response['results'][0]['formatted_address'];
             $lat = $response['results'][0]['geometry']['location']['lat'];
             $lng = $response['results'][0]['geometry']['location']['lng'];
             $db->update('sonnb_xengallery_location', array('location_name' => $address, 'location_lat' => $lat, 'location_lng' => $lng), array('location_id = ?' => $location['location_id']));
         } catch (Exception $e) {
             continue;
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:40,代码来源:Location.php

示例11: execute

 public function execute(array $deferred, array $data, $targetRunTime, &$status)
 {
     $data = array_merge(array('position' => 0, 'batch' => 70), $data);
     $data['batch'] = max(1, $data['batch']);
     /* @var $postModel XenForo_Model_Post */
     $postModel = XenForo_Model::create('XenForo_Model_Post');
     $postIds = $postModel->getPostIdsInRange($data['position'], $data['batch']);
     if (sizeof($postIds) == 0) {
         return true;
     }
     foreach ($postIds as $postId) {
         $data['position'] = $postId;
         /* @var $postDw XenForo_DataWriter_DiscussionMessage_Post */
         $postDw = XenForo_DataWriter::create('XenForo_DataWriter_DiscussionMessage_Post', XenForo_DataWriter::ERROR_SILENT);
         if ($postDw->setExistingData($postId)) {
             XenForo_Db::beginTransaction();
             $postDw->rebuildPostVerseCache();
             XenForo_Db::commit();
         }
     }
     $actionPhrase = new XenForo_Phrase('rebuilding');
     $typePhrase = new XenForo_Phrase('posts');
     $status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::numberFormat($data['position']));
     return $data;
 }
开发者ID:ThemeHouse-XF,项目名称:Biblea,代码行数:25,代码来源:PostVerse.php

示例12: rebuild

 /**
  * Rebuilds the data.
  *
  * @see XenForo_CacheRebuilder_Abstract::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options = array_merge(array('batch' => 100, 'positionRebuild' => false), $options);
     /* @var $threadModel XenForo_Model_Thread */
     $threadModel = XenForo_Model::create('XenForo_Model_Thread');
     $threadIds = $threadModel->getThreadIdsInRange($position, $options['batch']);
     if (sizeof($threadIds) == 0) {
         return true;
     }
     XenForo_Db::beginTransaction();
     foreach ($threadIds as $threadId) {
         $position = $threadId;
         $dw = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread', XenForo_DataWriter::ERROR_SILENT);
         if ($dw->setExistingData($threadId)) {
             $dw->setOption(XenForo_DataWriter_Discussion::OPTION_UPDATE_CONTAINER, false);
             if ($options['positionRebuild']) {
                 $dw->rebuildDiscussion();
             } else {
                 $dw->rebuildDiscussionCounters();
             }
             $dw->save();
         }
     }
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::numberFormat($position);
     return $position;
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:32,代码来源:Thread.php

示例13: initiate

 public static function initiate($method, array $args)
 {
     if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50307) {
         throw new GFNCore_Exception('This add-on does not support PHP versions lesser than 5.3.7', true);
     }
     if ($method == 'install' && !empty($args[0])) {
         $job = 'upgrade';
     } else {
         $job = $method;
     }
     /** @var GFNCore_Installer_Abstract $obj */
     $obj = new static();
     $obj->setJob($job);
     if ($method == 'install') {
         $obj->setNewData($args[1]);
         $obj->setXml($args[2]);
     }
     if (in_array($job, array('upgrade', 'uninstall'))) {
         $obj->setExistingData($args[0]);
     }
     $class = 'GFNCore_Installer_Controller_' . ucfirst($job);
     XenForo_Db::beginTransaction();
     try {
         /** @var GFNCore_Installer_Controller_Abstract $controller */
         $controller = new $class($obj);
         $controller->execute();
     } catch (Exception $e) {
         XenForo_Db::rollback();
         throw $e;
     }
     XenForo_Db::commit();
     $style = new GFNCore_Installer_Handler_Style();
     $style->handle($obj->getData()->addon_id);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:34,代码来源:Abstract.php

示例14: promoteUserWithEndDate

 /**
  * Gives a user the specified promotion.
  *
  * @param array $promotion
  * @param integer $userId
  * @param string $state Type of promotion (automatic, manual); this affects
  * automatic demotion
  * @param integer $endDate
  */
 public function promoteUserWithEndDate(array $promotion, $userId, $state = 'automatic', $endDate)
 {
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $this->_getUserModel()->addUserGroupChange($userId, "ugPromotion{$promotion['promotion_id']}", $promotion['extra_user_group_ids']);
     $this->insertPromotionLogEntryWithEndDate($promotion['promotion_id'], $userId, $state, $endDate);
     XenForo_Db::commit($db);
 }
开发者ID:ThemeHouse-XF,项目名称:PromotionEnd,代码行数:17,代码来源:UserGroupPromotion.php

示例15: uninstaller

 public static function uninstaller()
 {
     $db = self::_getDb();
     XenForo_Db::beginTransaction($db);
     if (self::_doesIndexExist()) {
         self::_dropIndex();
     }
     XenForo_Db::commit($db);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:9,代码来源:Install.php


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