Debian Codegraph @

vendor/symfony/polyfill-php84/Resources/stubs/Pdo/Pgsql.php

raw
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_pgsql')) {
15 class Pgsql extends \PDO
16 {
17 public const ATTR_DISABLE_PREPARES = \PDO::PGSQL_ATTR_DISABLE_PREPARES;
18
19 public function __construct(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null)
20 {
21 parent::__construct($dsn, $username, $password, $options);
22
23 if ('pgsql' !== $driver = $this->getAttribute(\PDO::ATTR_DRIVER_NAME)) {
24 throw new \PDOException(\sprintf('Pdo\Pgsql::__construct() cannot be used for connecting to the "%s" driver', $driver));
25 }
26 }
27
28 public static function connect(string $dsn, ?string $username = null, ?string $password = null, ?array $options = null): self
29 {
30 try {
31 return new self($dsn, $username, $password, $options);
32 } catch (\PDOException $e) {
33 throw preg_match('/^Pdo\\\\Pgsql::__construct\(\) cannot be used for connecting to the "([a-z]+)" driver/', $e->getMessage(), $matches) ? new \PDOException(\sprintf('Pdo\Pgsql::connect() cannot be used for connecting to the "%s" driver', $matches[1])) : $e;
34 }
35 }
36
37 public function copyFromArray(string $tableName, array $rows, string $separator = "\t", string $nullAs = '\\\\N', ?string $fields = null): bool
38 {
39 return $this->pgsqlCopyFromArray($tableName, $rows, $separator, $nullAs, $fields);
40 }
41
42 public function copyFromFile(string $tableName, string $filename, string $separator = "\t", string $nullAs = '\\\\N', ?string $fields = null): bool
43 {
44 return $this->pgsqlCopyFromFile($tableName, $filename, $separator, $nullAs, $fields);
45 }
46
47 /**
48 * @return array|false
49 */
50 public function copyToArray(string $tableName, string $separator = "\t", string $nullAs = '\\\\N', ?string $fields = null)
51 {
52 return $this->pgsqlCopyToArray($tableName, $separator, $nullAs, $fields);
53 }
54
55 public function copyToFile(string $tableName, string $filename, string $separator = "\t", string $nullAs = '\\\\N', ?string $fields = null): bool
56 {
57 return $this->pgsqlCopyToFile($tableName, $filename, $separator, $nullAs, $fields);
58 }
59
60 /**
61 * @return array|false
62 */
63 public function getNotify(int $fetchMode = \PDO::FETCH_DEFAULT, int $timeoutMilliseconds = 0)
64 {
65 return $this->pgsqlGetNotify($fetchMode, $timeoutMilliseconds);
66 }
67
68 public function getPid(): int
69 {
70 return $this->pgsqlGetPid();
71 }
72
73 /**
74 * @return string|false
75 */
76 public function lobCreate()
77 {
78 return $this->pgsqlLOBCreate();
79 }
80
81 /**
82 * @return resource|false
83 */
84 public function lobOpen(string $oid, string $mode = 'rb')
85 {
86 return $this->pgsqlLOBOpen($oid, $mode);
87 }
88
89 public function lobUnlink(string $oid): bool
90 {
91 return $this->pgsqlLOBUnlink($oid);
92 }
93 }
94 }