$query = sprintf(self::FIND_BY_NAME, $username); $result = self::$app->db->query($query, \PDO::FETCH_ASSOC); $row = $result->fetch(); if ($row == false) { return null; } return User::makeFromSql($row); } static function deleteByUsername($username) { $query = "DELETE FROM users WHERE user='******' "; return self::$app->db->exec($query); } static function all() { $query = "SELECT * FROM users"; $results = self::$app->db->query($query); $users = []; foreach ($results as $row) { $user = User::makeFromSql($row); array_push($users, $user); } return $users; } static function makeFromSql($row) { return User::make($row['id'], $row['user'], $row['pass'], $row['email'], $row['bio'], $row['age'], $row['isadmin']); } } User::$app = \Slim\Slim::getInstance();