pg_connect
Open a PostgreSQL connection.
pg_connect Function synopsis
pg_connect(string $connection_string, int $flags = 0): PgSql\Connection|false
Parameters
$connection_string
Typestring
The $connection_string can be empty to use all default parameters, or it
can contain one or more parameter settings separated by whitespace.
Each parameter setting is in the form keyword = value. Spaces around
the equal sign are optional. To write an empty value or a value
containing spaces, surround it with single quotes, e.g., keyword = 'a value'. Single quotes and backslashes within the value must be
escaped with a backslash, i.e., \' and \.
$flags
OptionalTypeintDefault value0
If PGSQL_CONNECT_FORCE_NEW is passed, then a new connection
is created, even if the $connection_string is identical to
an existing connection.
Return value
TypePgSql\Connection|false
Returns an PgSql\Connection instance on success, or false on failure.
Changes to the pg_connect Function
PHP 8.1
- Return type added:
PgSql\Connection|false
- pg_connect(string $connection_string, int $flags = 0)
+ pg_connect(string $connection_string, int $flags = 0): PgSql\Connection|false PHP 8.0
- Parameter count changed:
7to2 - Optional parameter removed - #3:
$host - Optional parameter removed - #4:
$port - Optional parameter removed - #5:
$options - Optional parameter removed - #6:
$tty - Optional parameter removed - #7:
$database
-pg_connect(
- $connection_string,
- $connect_type,
- $host,
- $port,
- $options,
- $tty,
- $database
- )
+pg_connect(string $connection_string, int $flags = 0) pg_connect Function Availability
pg_connect Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |