Skip to content

Commit

Permalink
Fixed DbFactory bug
Browse files Browse the repository at this point in the history
  • Loading branch information
robinsonjohn committed Sep 11, 2024
1 parent 5842cda commit 5a62563
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities

## [4.0.1] - 2024.09.10

### Fixed

- Fixed bug in `DbFactory` using old namespace.

## [4.0.0] - 2024.09.10

### Added
Expand Down
12 changes: 6 additions & 6 deletions src/DbFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ public static function create(array $array): Db

// Check valid adapter

if (!isset($db_config['adapter']) || !class_exists('Bayfront\PDO\Adapters\\' . $db_config['adapter'])) {
if (!isset($db_config['adapter']) || !class_exists('Bayfront\SimplePdo\\Adapters\\' . $db_config['adapter'])) {

throw new ConfigurationException('Invalid database configuration (' . $name . '): adapter not specified or does not exist');

}

/** @var AdapterInterface $adapter */

$adapter = 'Bayfront\PDO\Adapters\\' . $db_config['adapter'];
$adapter = 'Bayfront\SimplePdo\Adapters\\' . $db_config['adapter'];

if (isset($db_config['default']) && true === $db_config['default'] && !isset($db)) { // If default database

// Create connection

/*
* @throws Bayfront\PDO\Exceptions\ConfigurationException
* @throws Bayfront\PDO\Exceptions\UnableToConnectException
* @throws Bayfront\SimplePdo\Exceptions\ConfigurationException
* @throws Bayfront\SimplePdo\Exceptions\UnableToConnectException
*/

$pdo = $adapter::connect($db_config);
Expand All @@ -58,7 +58,7 @@ public static function create(array $array): Db
// Create connection

/*
* @throws Bayfront\PDO\Exceptions\PdoException
* @throws Bayfront\SimplePdo\Exceptions\PdoException
*/

$connections[$name] = $adapter::connect($db_config);
Expand All @@ -76,7 +76,7 @@ public static function create(array $array): Db
foreach ($connections as $name => $pdo) {

/*
* @throws Bayfront\PDO\Exceptions\InvalidDatabaseException
* @throws Bayfront\SimplePdo\Exceptions\InvalidDatabaseException
*/

$db->addConnection($pdo, $name); // Add all additional connections
Expand Down

0 comments on commit 5a62563

Please sign in to comment.