本文整理汇总了PHP中Group_member::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Group_member::update方法的具体用法?PHP Group_member::update怎么用?PHP Group_member::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group_member
的用法示例。
在下文中一共展示了Group_member::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
try {
$user = User::getKV('nickname', $nickname);
if (empty($user)) {
throw new Exception("No user named '{$nickname}'.");
}
$group = User_group::getKV('nickname', $groupname);
if (empty($group)) {
throw new Exception("No group named '{$groupname}'.");
}
$member = Group_member::pkeyGet(array('group_id' => $group->id, 'profile_id' => $user->id));
if (empty($member)) {
$member = new Group_member();
$member->group_id = $group->id;
$member->profile_id = $user->id;
$member->created = common_sql_now();
if (!$member->insert()) {
throw new Exception("Can't add '{$nickname}' to '{$groupname}'.");
}
}
if ($member->is_admin) {
throw new Exception("'{$nickname}' is already an admin of '{$groupname}'.");
}
$orig = clone $member;
$member->is_admin = 1;
if (!$member->update($orig)) {
throw new Exception("Can't make '{$nickname}' admin of '{$groupname}'.");
}
} catch (Exception $e) {
print $e->getMessage() . "\n";
exit(1);
}