Add mode, bring in definition/patch queries
This commit is contained in:
@@ -24,6 +24,9 @@ class Configuration
|
||||
/** @var array|null Options to use for connections (driver-specific) */
|
||||
public static ?array $options = null;
|
||||
|
||||
/** @var Mode|null The mode in which the library is operating (filled after first connection if not configured) */
|
||||
public static ?Mode $mode = null;
|
||||
|
||||
/**
|
||||
* Retrieve a new connection to the database
|
||||
*
|
||||
@@ -38,8 +41,15 @@ class Configuration
|
||||
$db = new PDO(self::$pdoDSN, $_ENV['PDO_DOC_USERNAME'] ?? self::$username,
|
||||
$_ENV['PDO_DOC_PASSWORD'] ?? self::$password, self::$options);
|
||||
|
||||
// TODO: determine driver, set mode for other queries
|
||||
echo $db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
if (is_null(self::$mode)) {
|
||||
$driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
self::$mode = match ($driver) {
|
||||
'pgsql' => Mode::PgSQL,
|
||||
'sqlite' => Mode::SQLite,
|
||||
default => throw new DocumentException(
|
||||
"Unsupported driver $driver: this library currently supports PostgreSQL and SQLite")
|
||||
};
|
||||
}
|
||||
return $db;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user