/** * User login * * @param LoginRequest $request * @return bool */ public static function login(LoginRequest $request) { $password = md5($request->password); $db = Db::getConnection(); $result = $db->query("SELECT id FROM user WHERE name = '{$request->name}' AND password = '******'"); $result->setFetchMode(PDO::FETCH_ASSOC); $userId = $result->fetch(); if ($userId === FALSE) { $response['error'] = self::ERROR_USER_NOT_FOUND; return $response; } self::auth($userId['id']); return true; }
/** * Set status edit feedback * * @param $id * @param $message * @return bool|string */ public static function edit($id, $message) { $userId = User::getId(); if ($userId) { try { $db = Db::getConnection(); $sqlInsert = "UPDATE `feedback` SET `message` = '{$message}', `edit` = '{$userId}' WHERE `id` =" . $id; $preparedStatement = $db->prepare($sqlInsert); $preparedStatement->execute(); return $message; } catch (PDOException $e) { return $e->getMessage(); } } return $error['error'] = self::ERROR_TOKEN_EXCEPTION; }