Files
PHP-EM-DB/database/abstracts/BaseAccess.php
2026-10-29 08:36:44 +09:00

49 lines
1.2 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once __DIR__ . '/../../config/db_config.php';
/**
* BaseAccessクラス(抽象クラス)
*
* データベースアクセスの基底クラスです。
* 共通のデータベース接続機能を提供します。
*/
abstract class BaseAccess
{
protected ?PDO $pdo = null;
/**
* コンストラクタ
* データベース接続を確立します。
*/
public function __construct()
{
try {
// TODO: PDOを使用してデータベースに接続してください
// ヒント: new PDO(DSN, ユーザー名, パスワード, オプション)
// 接続情報は config/db_config.php で定義されています
// ユーザー: rezouser
// パスワード: Rezo_0000
} catch (PDOException $e) {
throw new Exception("データベース接続エラー: " . $e->getMessage());
}
}
/**
* データベース接続を取得
*
* @return PDO PDOインスタンス
*/
public function getConnection(): PDO
{
return $this->pdo;
}
/**
* 接続を閉じる
*/
public function closeConnection(): void
{
$this->pdo = null;
}
}