diff --git a/controller/connect.php b/controller/connect.php index 96425bd..954a052 100644 --- a/controller/connect.php +++ b/controller/connect.php @@ -1,7 +1,10 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -}catch(PDOException $e){ - die($e->getMessage()); -} \ No newline at end of file +try { + $db = new PDO("mysql:host=localhost;dbname=rest-api;charset=UTF8", "user", "userpass", [ + PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, + PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, + ]); +} catch (PDOException $e) { + exit($e->getMessage()); +} +?>