本文整理匯總了PHP中Claroline\CoreBundle\Entity\User::getPlatformRole方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::getPlatformRole方法的具體用法?PHP User::getPlatformRole怎麽用?PHP User::getPlatformRole使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::getPlatformRole方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createInwicastUserIfNotExists
public function createInwicastUserIfNotExists(User $user, $token, Mediacenter $mediacenter)
{
$connection = $this->connectionFactory->createConnection($mediacenter->getDatabaseParameters());
$qb = $connection->createQueryBuilder();
$qb->select('usr.username, usr.token')->from('mdcr_inwicast_user_tokens', 'usr')->where('usr.username = :username')->andWhere('usr.tokenapp = :platform')->setParameter("username", $user->getUsername())->setParameter("platform", $this->platformName);
$result = $qb->execute()->fetch();
if (!$result) {
//$qb_insert = $connection->createQueryBuilder();
$sql = "INSERT INTO mdcr_inwicast_user_tokens" . " (`username`, `firstname`, `lastname`, `email`, `userrole`, `token`, `tokendate`, `tokenapp`)" . " VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$query = $connection->prepare($sql);
$query->bindValue(1, $user->getUsername());
$query->bindValue(2, $user->getFirstName());
$query->bindValue(3, $user->getLastName());
$query->bindValue(4, $user->getMail());
$query->bindValue(5, $user->getPlatformRole()->getName());
$query->bindValue(6, $token);
$query->bindValue(7, date('Y-m-d H:i:s'));
$query->bindValue(8, $this->platformName);
$query->execute();
} else {
$qb_update = $connection->createQueryBuilder();
$qb_update->update('mdcr_inwicast_user_tokens')->set('token', '?')->set('tokendate', '?')->set('tokenapp', '?')->where('username = ?')->setParameter(0, $token)->setParameter(1, date('Y-m-d H:i:s'))->setParameter(2, $this->platformName)->setParameter(3, $user->getUsername());
$qb_update->execute();
}
return true;
}