Update option/result library
- Restore getOrThrow() calls
This commit is contained in:
@@ -66,15 +66,14 @@ class Configuration
|
||||
* Retrieve a new connection to the database
|
||||
*
|
||||
* @return PDO A new connection to the SQLite database with foreign key support enabled
|
||||
* @throws DocumentException If this is called before a connection string is set
|
||||
* @throws Exception If this is called before a connection string is set
|
||||
*/
|
||||
public static function dbConn(): PDO
|
||||
{
|
||||
if (is_null(self::$pdo)) {
|
||||
if (self::$pdoDSN->isNone()) {
|
||||
throw new DocumentException('Please provide a data source name (DSN) before attempting data access');
|
||||
}
|
||||
self::$pdo = new PDO(self::$pdoDSN->get(), $_ENV['PDO_DOC_USERNAME'] ?? self::$username,
|
||||
$dsn = self::$pdoDSN->getOrThrow(fn()
|
||||
=> new DocumentException('Please provide a data source name (DSN) before attempting data access'));
|
||||
self::$pdo = new PDO($dsn, $_ENV['PDO_DOC_USERNAME'] ?? self::$username,
|
||||
$_ENV['PDO_DOC_PASSWORD'] ?? self::$password, self::$options);
|
||||
}
|
||||
|
||||
@@ -89,10 +88,8 @@ class Configuration
|
||||
*/
|
||||
public static function mode(?string $process = null): Mode
|
||||
{
|
||||
if (self::$mode->isNone()) {
|
||||
throw new DocumentException('Database mode not set' . (is_null($process) ? '' : "; cannot $process"));
|
||||
}
|
||||
return self::$mode->get();
|
||||
return self::$mode->getOrThrow(fn()
|
||||
=> new DocumentException('Database mode not set' . (is_null($process) ? '' : "; cannot $process")));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user