no message
This commit is contained in:
48
database/abstracts/BaseAccess.php
Normal file
48
database/abstracts/BaseAccess.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user