| Conditions | 4 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | public function __construct( \PDO $pdo, UserAbstract $user = null, $table = null ) |
||
| 25 | { |
||
| 26 | $this->table = $table ?: $this->table; |
||
| 27 | |||
| 28 | // ID is listed twice here in order to use it with FETCH_UNIQUE as array key |
||
| 29 | $sql = "SELECT |
||
| 30 | id, |
||
| 31 | id AS id, |
||
| 32 | user_first_name AS first_name, |
||
| 33 | user_last_name AS last_name, |
||
| 34 | user_login_name AS login_name, |
||
| 35 | user_display_name AS display_name, |
||
| 36 | user_email AS email, |
||
| 37 | api_key AS api_key, |
||
| 38 | is_active AS is_active, |
||
| 39 | created AS created, |
||
| 40 | updated AS updated, |
||
| 41 | |||
| 42 | |||
| 43 | FROM {$this->table}"; |
||
| 44 | |||
| 45 | $stmt = $pdo->prepare( $sql ); |
||
| 46 | |||
| 47 | $stmt->setFetchMode( \PDO::FETCH_CLASS, $user ? get_class($user) : User::class ); |
||
|
|
|||
| 48 | |||
| 49 | if (!$stmt->execute()): |
||
| 50 | throw new \RuntimeException("Could not retrieve Users from database"); |
||
| 51 | endif; |
||
| 52 | |||
| 53 | $this->users = $stmt->fetchAll(\PDO::FETCH_UNIQUE); |
||
| 54 | } |
||
| 58 |