|
@@ 40-57 (lines=18) @@
|
| 37 |
|
* @param string $username The username to find. |
| 38 |
|
* @return int |
| 39 |
|
*/ |
| 40 |
|
public function getId($databaseName, $username) |
| 41 |
|
{ |
| 42 |
|
$cacheKey = $this->getCacheKey(func_get_args(), 'user_id'); |
| 43 |
|
if ($this->cache->hasItem($cacheKey)) { |
| 44 |
|
return $this->cache->getItem($cacheKey)->get(); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
$userTable = $this->getTableName($databaseName, 'user'); |
| 48 |
|
$sql = "SELECT user_id FROM $userTable WHERE user_name = :username LIMIT 1"; |
| 49 |
|
$resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 50 |
|
$resultQuery->bindParam('username', $username); |
| 51 |
|
$resultQuery->execute(); |
| 52 |
|
$userId = (int)$resultQuery->fetchColumn(); |
| 53 |
|
|
| 54 |
|
// Cache for 10 minutes and return. |
| 55 |
|
$this->setCache($cacheKey, $userId); |
| 56 |
|
return $userId; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
/** |
| 60 |
|
* Get the user's registration date. |
|
@@ 65-82 (lines=18) @@
|
| 62 |
|
* @param string $username The username to find. |
| 63 |
|
* @return string|null As returned by the database. |
| 64 |
|
*/ |
| 65 |
|
public function getRegistrationDate($databaseName, $username) |
| 66 |
|
{ |
| 67 |
|
$cacheKey = $this->getCacheKey(func_get_args(), 'user_registration'); |
| 68 |
|
if ($this->cache->hasItem($cacheKey)) { |
| 69 |
|
return $this->cache->getItem($cacheKey)->get(); |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
$userTable = $this->getTableName($databaseName, 'user'); |
| 73 |
|
$sql = "SELECT user_registration FROM $userTable WHERE user_name = :username LIMIT 1"; |
| 74 |
|
$resultQuery = $this->getProjectsConnection()->prepare($sql); |
| 75 |
|
$resultQuery->bindParam('username', $username); |
| 76 |
|
$resultQuery->execute(); |
| 77 |
|
$registrationDate = $resultQuery->fetchColumn(); |
| 78 |
|
|
| 79 |
|
// Cache and return. |
| 80 |
|
$this->setCache($cacheKey, $registrationDate); |
| 81 |
|
return $registrationDate; |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
/** |
| 85 |
|
* Get the user's (system) edit count. |