NaifyDb\Connection\ConnectionConfigInterface インターフェース
ConnectionConfigInterface — NaifyDb が受け取る接続設定 contract
NaifyDb::configure()->loadConfig(...)->apply() の正規ルートで受け取る
object contract。
built-in では Adapter がこの interface を実装し、DB 方言ごとの
DSN・認証情報・識別子クオート・metadata 取得をひとまとめに提供する。
目的:
- public API を「設定 object を渡す」流れへ揃える
- 配列設定は
loadConfigArray()の補助ルートへ分離する - 設定ファイルも object を返せるようにして、DB 方言や profiler の情報を保ったまま渡す
使用例
$config = Mysql::configure()
->host('127.0.0.1')
->database('app')
->username('root')
->password('secret');
NaifyDb::configure()->loadConfig('main', $config)->apply();
$db = NaifyDb::db('main');
メソッド
| メソッド | 説明 |
|---|---|
public
toDsn(): string
|
PDO DSN を返す |
public
getUsername(): ?string
|
接続ユーザー名を返す |
public
getPassword(): ?string
|
接続パスワードを返す |
public
getOptions(): array
|
PDO options を返す |
public
getProfiler(): ?QueryProfilerInterface
|
クエリプロファイラを返す |
public
quoteIdentifier(string $identifier): string
|
識別子をクオートする |
public
getMetadata(): MetadataInterface
|
metadata provider を返す |
public
describeTable(PDO $pdo, string $tableName): array
|
テーブル定義を直接取得する |