本文整理汇总了PHP中Model\User::GetPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP User::GetPassword方法的具体用法?PHP User::GetPassword怎么用?PHP User::GetPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::GetPassword方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add(User $user)
{
// If Empty user submit throw Exception.
if ($getUser = $this->getUserByUsername($user->GetUsername())) {
throw new DbUserExistException();
}
try {
$db = $this->connection();
$sql = "INSERT INTO " . self::$dbTable . " (" . self::$userName . ", " . self::$password . ") VALUES (?, ?)";
$params = array($user->GetUsername(), $user->GetPassword());
$query = $db->prepare($sql);
$query->execute($params);
} catch (\PDOException $e) {
throw new \Exception();
}
}
示例2: Add
public function Add(\model\User $user)
{
if ($this->GetRegistrationsForHour() > self::$MAX_REGISTRATIONS_PER_HOUR) {
throw new \Exception("Max number of registrations per hour reached. Please try again in 30-60 minutes.");
}
// Throw exception if username is taken
if ($this->GetUserByUsername($user->GetUserName())) {
throw new \Exception(self::$DB_USERNAME_EXISTS);
}
try {
// Prepare db statement
$statement = self::$db->prepare('INSERT INTO ' . self::$DB_TABLE_NAME . '(user_id, user_name, user_password, date_time)' . ' VALUES ' . '(NULL, :userName, :password, NOW())');
// Prepare input array
$inputArray = ['userName' => $user->GetUserName(), 'password' => $user->GetPassword()];
// Execute db statement
$statement->execute($inputArray);
// Check if db insertion was successful
return $statement->rowCount() == 1;
} catch (\Exception $exception) {
throw new \Exception(self::$DB_INSERT_ERROR);
}
}