本文整理匯總了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);
}