diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/OCI8/Driver.php')
| -rw-r--r-- | vendor/doctrine/dbal/src/Driver/OCI8/Driver.php | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php b/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php new file mode 100644 index 0000000..1b0afbf --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/Driver.php | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver\OCI8; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\Driver\AbstractOracleDriver; | ||
| 8 | use Doctrine\DBAL\Driver\OCI8\Exception\ConnectionFailed; | ||
| 9 | use Doctrine\DBAL\Driver\OCI8\Exception\InvalidConfiguration; | ||
| 10 | use SensitiveParameter; | ||
| 11 | |||
| 12 | use function oci_connect; | ||
| 13 | use function oci_new_connect; | ||
| 14 | use function oci_pconnect; | ||
| 15 | |||
| 16 | use const OCI_NO_AUTO_COMMIT; | ||
| 17 | |||
| 18 | /** | ||
| 19 | * A Doctrine DBAL driver for the Oracle OCI8 PHP extensions. | ||
| 20 | */ | ||
| 21 | final class Driver extends AbstractOracleDriver | ||
| 22 | { | ||
| 23 | /** | ||
| 24 | * {@inheritDoc} | ||
| 25 | */ | ||
| 26 | public function connect( | ||
| 27 | #[SensitiveParameter] | ||
| 28 | array $params, | ||
| 29 | ): Connection { | ||
| 30 | $username = $params['user'] ?? ''; | ||
| 31 | $password = $params['password'] ?? ''; | ||
| 32 | $charset = $params['charset'] ?? ''; | ||
| 33 | $sessionMode = $params['sessionMode'] ?? OCI_NO_AUTO_COMMIT; | ||
| 34 | |||
| 35 | $connectionString = $this->getEasyConnectString($params); | ||
| 36 | |||
| 37 | /** @psalm-suppress RiskyTruthyFalsyComparison */ | ||
| 38 | $persistent = ! empty($params['persistent']); | ||
| 39 | /** @psalm-suppress RiskyTruthyFalsyComparison */ | ||
| 40 | $exclusive = ! empty($params['driverOptions']['exclusive']); | ||
| 41 | |||
| 42 | if ($persistent && $exclusive) { | ||
| 43 | throw InvalidConfiguration::forPersistentAndExclusive(); | ||
| 44 | } | ||
| 45 | |||
| 46 | if ($persistent) { | ||
| 47 | $connection = @oci_pconnect($username, $password, $connectionString, $charset, $sessionMode); | ||
| 48 | } elseif ($exclusive) { | ||
| 49 | $connection = @oci_new_connect($username, $password, $connectionString, $charset, $sessionMode); | ||
| 50 | } else { | ||
| 51 | $connection = @oci_connect($username, $password, $connectionString, $charset, $sessionMode); | ||
| 52 | } | ||
| 53 | |||
| 54 | if ($connection === false) { | ||
| 55 | throw ConnectionFailed::new(); | ||
| 56 | } | ||
| 57 | |||
| 58 | return new Connection($connection); | ||
| 59 | } | ||
| 60 | } | ||
