diff --git a/Ex01.php b/Ex01.php index 02576ef..a155a86 100644 --- a/Ex01.php +++ b/Ex01.php @@ -12,3 +12,20 @@ * * ※この問題を解く前に、setup.sql を実行してデータベースをセットアップしてください。 */ + + +// DSN は "mysql:host=localhost;dbname=employee_db;charset=utf8" +$dsn = 'mysql:host=localhost;dbname=employee_db;charset=utf8'; +// データベース接続に必要なユーザ名とパスワード +$user = "rezouser"; +$password = 'Rezo_0000'; + +try{ + // 橋をかける + $dbh = new PDO($dsn, $user, $password); + echo '接続しました'; +} catch (Throwable $th){ + echo '失敗しました: ' . $th->getMessage(); + } finally { + $dbh = null; +} \ No newline at end of file