| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* This file is part of the Symfony package. |
| 5 |
* |
| 6 |
* (c) Fabien Potencier <[email protected]> |
| 7 |
* |
| 8 |
* For the full copyright and license information, please view the LICENSE |
| 9 |
* file that was distributed with this source code. |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace Pdo; |
| 13 |
|
| 14 |
if (\PHP_VERSION_ID < 80400 && \extension_loaded('pdo_firebird')) { |
| 15 |
class Firebird extends \PDO |
| 16 |
{ |
| 17 |
public const ATTR_DATE_FORMAT = \PDO::FB_ATTR_DATE_FORMAT; |
| 18 |
public const ATTR_TIME_FORMAT = \PDO::FB_ATTR_TIME_FORMAT; |
| 19 |
public const ATTR_TIMESTAMP_FORMAT = \PDO::FB_ATTR_TIMESTAMP_FORMAT; |
| 20 |
|
| 21 |
public function __construct(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null) |
| 22 |
{ |
| 23 |
parent::__construct($dsn, $username, $password, $options); |
| 24 |
|
| 25 |
if ('firebird' !== $driver = $this->getAttribute(\PDO::ATTR_DRIVER_NAME)) { |
| 26 |
throw new \PDOException(\sprintf('Pdo\Firebird::__construct() cannot be used for connecting to the "%s" driver', $driver)); |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
public static function connect(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null): self |
| 31 |
{ |
| 32 |
try { |
| 33 |
return new self($dsn, $username, $password, $options); |
| 34 |
} catch (\PDOException $e) { |
| 35 |
throw preg_match('/^Pdo\\\\Firebird::__construct\(\) cannot be used for connecting to the "([a-z]+)" driver/', $e->getMessage(), $matches) ? new \PDOException(\sprintf('Pdo\Firebird::connect() cannot be used for connecting to the "%s" driver', $matches[1])) : $e; |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |