Skip to content

Commit

Permalink
## Version 2.8.2
Browse files Browse the repository at this point in the history
Add `shouldConnectFirst` for Ark Quick Access for PDO.
  • Loading branch information
sinri committed Aug 13, 2019
1 parent a95cdea commit 9e21be8
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 89 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

For the serial of previous versions, see related branch.

## Version 2.8.2

Add `shouldConnectFirst` for Ark Quick Access for PDO.

## Version 2.8.1

Deprecate `Ark()->db()` and replace it with `Ark()->pdo()`.
Expand Down
176 changes: 88 additions & 88 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/TheArk.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace sinri\ark;


use Exception;
use Psr\Log\LogLevel;
use sinri\ark\cache\ArkCache;
use sinri\ark\cache\implement\ArkDummyCache;
Expand Down Expand Up @@ -169,6 +170,7 @@ public function registerDb($name, $pdo)
*
* @param string $name
* @return ArkPDO
* @throws Exception
* @deprecated Please use method `pdo` and this would be removed in 3.x
*/
public function db($name = 'default'): ArkPDO
Expand All @@ -180,11 +182,13 @@ public function db($name = 'default'): ArkPDO
* Register an instance of ArkPDO based on the config item [pdo][NAME]
*
* @param string $name
* @param bool $shouldConnectFirst @since 2.8.2
* @return ArkPDO
*
* @throws Exception
* @since 2.8.1
*/
public function pdo($name = 'default'): ArkPDO
public function pdo($name = 'default', $shouldConnectFirst = true): ArkPDO
{
$pdo = ArkHelper::readTarget($this->pdoDict, $name);
if (!$pdo) {
Expand All @@ -194,6 +198,7 @@ public function pdo($name = 'default'): ArkPDO
} else {
$pdoConfig = new ArkPDOConfig($dbConfigDict);
$pdo = new ArkPDO($pdoConfig);
if ($shouldConnectFirst) $pdo->connect();
}
$this->registerDb($name, $pdo);
}
Expand Down

0 comments on commit 9e21be8

Please sign in to comment.