The Pdo\Pgsql class
A PDO subclass representing a connection using the PostgreSQL PDO driver.
Intro
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.
Class synopsis
PdoPgsqlextendsPDOInheritedConstantsConstantspublicconstintPdo\Pgsql::ATTR_DISABLE_PREPARESpublicconstintPdo\Pgsql::ATTR_RESULT_MEMORY_SIZEpublicconstintPdo\Pgsql::TRANSACTION_IDLEpublicconstintPdo\Pgsql::TRANSACTION_ACTIVEpublicconstintPdo\Pgsql::TRANSACTION_INTRANSpublicconstintPdo\Pgsql::TRANSACTION_INERRORpublicconstintPdo\Pgsql::TRANSACTION_UNKNOWNMethodsInheritedMethods
Predefined Constants
Pdo\Pgsql::ATTR_DISABLE_PREPARESSend 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_SIZEReturns the amount of memory, in bytes, allocated to the specified query result
PDOStatementinstance, or null if no results exist before the query is executed.PDO::ATTR_PREFETCHAs of PHP 8.5.0, setting this attribute to
0enables 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 firstPDOStatement::fetchcall. 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 thePDO::prepareorPDO::querydriver options.CautionIn 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::TRANSACTION_IDLE- Warning
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_ACTIVE- Warning
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_INTRANS- Warning
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_INERROR- Warning
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pdo\Pgsql::TRANSACTION_UNKNOWN- Warning
This constant has no effect, and is deprecated as of PHP 8.5.0.
Pgsql