本文整理汇总了PHP中modX::commit方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::commit方法的具体用法?PHP modX::commit怎么用?PHP modX::commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::commit方法的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;
}
示例2: merge
//.........这里部分代码省略.........
$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);
/* merge in disUserNotification */
$sql = 'UPDATE ' . $this->xpdo->getTableName('disUserNotification') . '
SET `user` = ' . $this->get('id') . '
WHERE `user` = ' . $oldUser->get('id') . '
';
$this->xpdo->query($sql);
/* merge in disModerator */
$sql = 'UPDATE ' . $this->xpdo->getTableName('disModerator') . '
SET `user` = ' . $this->get('id') . '
WHERE `user` = ' . $oldUser->get('id') . '
';
$this->xpdo->query($sql);
/* remove old user sessions */
$sql = 'DELETE FROM ' . $this->xpdo->getTableName('disUserFriend') . '
WHERE `user` = ' . $oldUser->get('id') . '
';
$this->xpdo->query($sql);
/* merge all PMs users fields for user */
$c = $this->xpdo->newQuery('disThread');
$c->innerJoin('disThreadUser', 'Users');
$c->leftJoin('disThreadRead', 'Reads', 'Reads.user = ' . $oldUser->get('id') . ' AND disThread.id = Reads.thread');
$c->where(array('disThread.private' => true, 'Users.user' => $oldUser->get('id')));
$pms = $this->xpdo->getCollection('disThread', $c);
foreach ($pms as $pm) {
$users = $pm->get('users');
$users = explode(',', $users);
$users = array_diff($users, array($oldUser->get('id')));
$users[] = $this->get('id');
$pm->set('users', implode(',', $users));
$pm->save();
}
/* remove old users */
$oldUser->remove();
$oldModxUser->remove();
/* check for post group advance */
$this->checkForPostGroupAdvance();
$this->xpdo->commit();
return $success;
}