The Pdo\Pgsql class
(PHP 8 >= 8.4.0)
简介
A PDO subclass representing a connection using the PostgreSQL PDO driver.
This driver supports a dedicated SQL query parser for the PostgreSQL dialect. It can handle the following:
-
Single and double-quoted literals, with doubling as escaping mechanism
-
C-style “escape” string literals
-
Dollar-quoted string literals
-
Two-dashes and C-style comments (non-nested).
-
Support for
??as escape sequence for the?operator.
注意:
Because this parser recognizes dollar-quoted string literals, question marks inside them are not treated as parameter placeholders and do not need to be escaped. As of PHP 8.4.0, escaping question marks as
??inside a dollar-quoted string is deprecated.
类摘要
string
$tableName,array|Traversable
$rows,string
$separator = "\t",string
$nullAs = "\\\\N",?string
$fields = null): bool
string
$tableName,string
$filename,string
$separator = "\t",string
$nullAs = "\\\\N",?string
$fields = null): bool
string
$tableName,string
$separator = "\t",string
$nullAs = "\\\\N",?string
$fields = null): array|false
string
$tableName,string
$filename,string
$separator = "\t",string
$nullAs = "\\\\N",?string
$fields = null): bool
$fetchMode = PDO::FETCH_DEFAULT, int $timeoutMilliseconds = 0): array|falsestring
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null)
string
$dsn,?string
$username = null,#[\SensitiveParameter] ?string
$password = null,?array
$options = null): static
$query, ?int $fetchMode = PDO::FETCH_COLUMN, int $colno): PDOStatement|falsestring
$query,?int
$fetchMode = PDO::FETCH_CLASS,string
$classname,array
$constructorArgs): PDOStatement|false
$query, ?int $fetchMode = PDO::FETCH_INTO, object $object): PDOStatement|false预定义常量
Pdo\Pgsql::ATTR_DISABLE_PREPARES
Send the query and the parameters to the server together in a single call, avoiding the need to create a named prepared statement separately. If the query is only going to be executed once this can reduce latency by avoiding an unnecessary server round-trip.
Pdo\Pgsql::ATTR_RESULT_MEMORY_SIZE
Returns the amount of memory, in bytes, allocated to the specified
query result PDOStatement instance,
or null if no results exist before the query is executed.
PDO::ATTR_PREFETCH
As of PHP 8.5.0, setting this attribute to 0 enables
lazy (single-row) fetching: rows are retrieved from the server one at a
time as they are fetched, instead of buffering the whole result set in
memory before the first PDOStatement::fetch()
call. This reduces memory usage for large result sets. Any other value
keeps the default buffered behavior.
It can be set per connection with PDO::setAttribute(), or per statement via the PDO::prepare() driver options.
With lazy fetching, PDOStatement::rowCount() returns the number of rows most recently retrieved from the server, not the total.
In lazy mode, a connection can have only one active statement at a time. Running another statement silently discards any unread rows of the previous one; no error is raised.
Pdo\Pgsql::ATTR_CHUNK_SIZE
The maximum number of rows retrieved from the server at a time during lazy fetching. It allows balancing speed against memory usage.
A value from 1 to 2147483647
enables lazy fetching and takes precedence over
PDO::ATTR_PREFETCH.
With the default value of 0,
PDO::ATTR_PREFETCH determines how rows are fetched.
Other integers throw a ValueError.
Like PDO::ATTR_PREFETCH, it can be set per
connection or per statement.
Setting PDO::ATTR_PREFETCH on the connection or on
a statement overrides the connection's chunk size.
A statement with PDO::ATTR_CURSOR set to
PDO::CURSOR_SCROLL ignores the connection's chunk
size.
Setting this attribute to 1 or more on such a
statement throws a ValueError.
For the caveats of lazy fetching, see PDO::ATTR_PREFETCH.
Available as of PHP 8.6.0, when compiled against libpq >= 17.
Pdo\Pgsql::TRANSACTION_IDLE
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_ACTIVE
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_INTRANS
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_INERROR
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_UNKNOWN
This constant has no effect, and is deprecated as of PHP 8.5.0.
目录
- Pdo\Pgsql::copyFromArray — Copy data from a PHP array into a table
- Pdo\Pgsql::copyFromFile — Copy data from file into table
- Pdo\Pgsql::copyToArray — Copy data from database table into PHP array
- Pdo\Pgsql::copyToFile — Copy data from table into file
- Pdo\Pgsql::escapeIdentifier — Escapes a string for use as an SQL identifier
- Pdo\Pgsql::getNotify — Get asynchronous notification
- Pdo\Pgsql::getPid — Get the PID of the backend process handling this connection
- Pdo\Pgsql::lobCreate — Creates a new large object
- Pdo\Pgsql::lobOpen — Opens an existing large object stream
- Pdo\Pgsql::lobUnlink — Deletes the large object
- Pdo\Pgsql::setNoticeCallback — Set a callback to handle notice and warning messages generated by the backend
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
