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


PHP modX::beginTransaction方法代码示例

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


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

示例1: generatePaths

 /** Generate paths */
 public static function generatePaths($ids = true)
 {
     if (!($tree = self::getTree($ids))) {
         return false;
     }
     self::$modx->beginTransaction();
     if ($ids === true) {
         self::$modx->query("TRUNCATE " . self::$PathTable);
     }
     $sql = "INSERT INTO " . self::$PathTable . " (`id`, `parent`, `level`, `order`) VALUES (:id, :parent, :level, :order)";
     $stmt = self::$modx->prepare($sql);
     try {
         self::walkthruTree($tree, $stmt, $ids);
         self::$modx->commit();
     } catch (Exception $e) {
         echo $e->getMessage();
         self::$modx->rollBack();
     }
     return true;
 }
开发者ID:vgrish,项目名称:mlmsystem,代码行数:21,代码来源:systempaths.class.php

示例2: merge

 /**
  * Merge another user into this account
  *
  * @param disUser $oldUser
  * @return boolean
  */
 public function merge(disUser &$oldUser)
 {
     $success = true;
     $user = $this->getOne('User');
     if (empty($user)) {
         return false;
     }
     $oldModxUser = $oldUser->getOne('User');
     if (empty($oldModxUser)) {
         return false;
     }
     $this->xpdo->beginTransaction();
     /* merge post count */
     $posts = $user->get('posts');
     $posts = $posts + $oldUser->get('posts');
     $this->set('posts', $posts);
     /* merge ignore boards */
     $ibs = $this->get('ignore_boards');
     $ibs = explode(',', $ibs);
     $oldIbs = $oldUser->get('ignore_boards');
     $oldIbs = explode(',', $oldIbs);
     $ibs = array_merge($oldIbs, $ibs);
     $this->set('ignore_boards', implode(',', $ibs));
     /* merge signature if needed */
     $signature = $this->get('signature');
     $oldSignature = $oldUser->get('signature');
     if (empty($signature) && !empty($oldSignature)) {
         $this->set('signature', $oldSignature);
     }
     /* merge title if needed */
     $title = $this->get('title');
     $oldTitle = $oldUser->get('title');
     if (empty($title) && !empty($oldTitle)) {
         $this->set('title', $oldTitle);
     }
     /* merge primary_group if needed */
     $pg = $this->get('primary_group');
     $oldPg = $oldUser->get('primary_group');
     if (empty($pg) && !empty($oldPg)) {
         $this->set('primary_group', $oldPg);
     }
     $this->set('integrated_id', $oldUser->get('integrated_id'));
     $this->set('synced', true);
     $this->set('syncedat', $this->xpdo->discuss->now());
     $this->save();
     /* grant old usergroups to this user */
     $oldUserGroups = $this->xpdo->getCollection('modUserGroupMember', array('member' => $oldModxUser->get('id')));
     $ugs = array();
     foreach ($oldUserGroups as $oldUserGroup) {
         $ugs[] = $oldUserGroup->get('user_group');
     }
     $ugs = array_unique($ugs);
     foreach ($ugs as $ug) {
         $user->joinGroup($ug);
     }
     /* merge in posts, change authors */
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disPost') . '
         SET `author` = ' . $this->get('id') . '
         WHERE `author` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disThread') . '
         SET `author_first` = ' . $this->get('id') . '
         WHERE `author_first` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disThread') . '
         SET `author_last` = ' . $this->get('id') . '
         WHERE `author_last` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     /* merge in disThreadRead */
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disThreadRead') . '
         SET `user` = ' . $this->get('id') . '
         WHERE `user` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     /* merge in disThreadUser */
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disThreadUser') . '
         SET `user` = ' . $this->get('id') . '
         WHERE `user` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     /* merge in disUserFriend */
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disUserFriend') . '
         SET `user` = ' . $this->get('id') . '
         WHERE `user` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
     $sql = 'UPDATE ' . $this->xpdo->getTableName('disUserFriend') . '
         SET `friend` = ' . $this->get('id') . '
         WHERE `friend` = ' . $oldUser->get('id') . '
     ';
     $this->xpdo->query($sql);
//.........这里部分代码省略.........
开发者ID:oneismore,项目名称:Discuss,代码行数:101,代码来源:disuser.class.php


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