szurubooru/src/Dao/UserDao.php

40 lines
876 B
PHP
Raw Normal View History

<?php
namespace Szurubooru\Dao;
class UserDao extends AbstractDao implements ICrudDao
{
public function __construct(\Szurubooru\DatabaseConnection $databaseConnection)
{
parent::__construct(
$databaseConnection,
'users',
new \Szurubooru\Dao\EntityConverters\UserEntityConverter());
}
public function findByName($userName)
{
2014-09-14 16:16:15 +02:00
return $this->findOneBy('name', $userName);
}
2014-09-01 19:43:49 +02:00
public function findByEmail($userEmail, $allowUnconfirmed = false)
{
2014-09-14 16:16:15 +02:00
$result = $this->findOneBy('email', $userEmail);
if (!$result and $allowUnconfirmed)
{
$result = $this->findOneBy('emailUnconfirmed', $userEmail);
}
return $result;
}
2014-09-01 19:43:49 +02:00
public function hasAnyUsers()
{
2014-09-14 16:16:15 +02:00
return $this->hasAnyRecords();
2014-09-01 19:43:49 +02:00
}
2014-09-05 13:50:51 +02:00
public function deleteByName($userName)
{
2014-09-14 16:16:15 +02:00
$this->deleteBy('name', $userName);
$this->fpdo->deleteFrom('tokens')->where('additionalData', $userName);
2014-09-05 13:50:51 +02:00
}
}