本文整理匯總了PHP中UserProfile::setNetId方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserProfile::setNetId方法的具體用法?PHP UserProfile::setNetId怎麽用?PHP UserProfile::setNetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserProfile
的用法示例。
在下文中一共展示了UserProfile::setNetId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUserAndProfile
protected function createUserAndProfile($username, $con = null)
{
// no user with this username
if (null === $con) {
$con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME);
}
try {
$con->begin();
// create a new user object
$user = new sfGuardUser();
$user->setUsername($username);
$user->setIsActive(1);
$user->setAlgorithm('');
$user->save($con);
// do we have a profile in the system with this net_id?
// this could happen if the profile was added manually by an admin
$userProfile = UserProfilePeer::selectByNetIdWithNoUserId($username);
if ($userProfile) {
// there is already a dangling user profile with this net id, link the user with the profile
$userProfile->setUserId($user->getId());
$userProfile->save($con);
} else {
// make a new user profile
$userProfile = new UserProfile();
$userProfile->setUserId($user->getId());
$userProfile->setNetId($user->getUsername());
$userProfile->save($con);
}
$con->commit();
} catch (PropelException $e) {
$con->rollback();
throw $e;
}
return $user;
}