Skip to content

Commit

Permalink
Remove PHP_VERSION_ID >= 80100 check (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov authored Aug 29, 2024
1 parent db41431 commit 1b5a917
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Chg #339: Replace call of `SchemaInterface::getRawTableName()` to `QuoterInterface::getRawTableName()` (@Tigrov)
- Enh #342: Add JSON overlaps condition builder (@Tigrov)
- Enh #344: Update `bit` type according to main PR yiisoft/db#860 (@Tigrov)
- Enh #347: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov)
- Enh #347, #353: Raise minimum PHP version to `^8.1` with minor refactoring (@Tigrov)
- Bug #349: Restore connection if closed by connection timeout (@Tigrov)

## 1.2.0 March 21, 2024
Expand Down
13 changes: 5 additions & 8 deletions src/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@ final class Driver extends AbstractPdoDriver
{
public function createConnection(): PDO
{
$this->attributes += [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];

if (PHP_VERSION_ID >= 80100) {
$this->attributes += [PDO::ATTR_STRINGIFY_FETCHES => true];
}
$this->attributes += [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_STRINGIFY_FETCHES => true,
];

$pdo = parent::createConnection();

if ($this->charset !== null) {
$pdo->exec('SET NAMES ' . $pdo->quote($this->charset));
}

if ($this->charset === null && !str_contains($this->dsn, 'charset')) {
} elseif (!str_contains($this->dsn, 'charset')) {
$pdo->exec('SET NAMES ' . $pdo->quote('utf8mb4'));
}

Expand Down

0 comments on commit 1b5a917

Please sign in to comment.