pg_select
Select records.
pg_select Function synopsis
pg_select(
PgSql\Connection $connection,
string $table_name,
array $conditions = [],
int $flags = PGSQL_DML_EXEC,
int $mode = PGSQL_ASSOC
): array|string|false
Parameters
$connection
TypePgSql\Connection
$table_name
Typestring
Name of the table from which to select rows.
$conditions
OptionalTypearrayDefault value[]
An array whose keys are field names in the table $table_name,
and whose values are the conditions that a row must meet to be retrieved.
As of PHP 8.4.0, when an empty array is provided, no conditions will apply.
Previously, the function failed with an empty $conditions argument.
$flags
OptionalTypeintDefault valuePGSQL_DML_EXEC
Any number of PGSQL_CONV_FORCE_NULL,
PGSQL_DML_NO_CONV,
PGSQL_DML_ESCAPE,
PGSQL_DML_EXEC,
PGSQL_DML_ASYNC or
PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the
$flags then the query string is returned. When PGSQL_DML_NO_CONV
or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally.
$flags accepts one or a bitmask of the following constant values:
$mode
OptionalTypeintDefault valuePGSQL_ASSOC
Any number of PGSQL_ASSOC,
PGSQL_NUM or
PGSQL_BOTH
If PGSQL_ASSOC is set the return value will be an associative array,
with PGSQL_NUM the return value will be an array, and
with PGSQL_BOTH the return value will be both an associative and
numerically indexed array.
$mode accepts one of the following constant values:
Return value
Typearray|string|false
Returns string if PGSQL_DML_STRING is passed
via $flags, otherwise it returns an array on success, or false on failure.
Changes to the pg_select Function
PHP 8.4
- Parameter default value added for position #3 (
$conditions):[]
pg_select(
PgSql\Connection $connection,
string $table_name,
- array $conditions,
+ array $conditions = [],
int $flags = PGSQL_DML_EXEC,
int $mode = PGSQL_ASSOC
): array|string|false PHP 8.1
- Parameter type added for parameter #1 (
$connection):PgSql\Connection
pg_select(
- $connection,
+ PgSql\Connection $connection,
string $table_name,
array $conditions,
int $flags = PGSQL_DML_EXEC,
int $mode = PGSQL_ASSOC
): array|string|false PHP 8.0
- Return type added:
array|string|false - Parameter name of parameter #1 changed:
$dbto$connection - Parameter name of parameter #2 changed:
$tableto$table_name - Parameter type added for parameter #2 (
$table_name):string - Parameter name of parameter #3 changed:
$idsto$conditions - Parameter type added for parameter #3 (
$conditions):array - Parameter name of parameter #4 changed:
$optionsto$flags - Parameter type added for parameter #4 (
$flags):int - Parameter default value added for position #4 (
$flags):PGSQL_DML_EXEC - Parameter name of parameter #5 changed:
$result_typeto$mode - Parameter type added for parameter #5 (
$mode):int - Parameter default value added for position #5 (
$mode):PGSQL_ASSOC
pg_select(
- $db,
+ $connection,
- $table,
+ string $table_name,
- $ids,
+ array $conditions,
- $options,
+ int $flags = PGSQL_DML_EXEC,
- $result_type
+ int $mode = PGSQL_ASSOC
- )
+ ): array|string|false PHP 7.1
- Optional parameter added - #5:
$result_type
pg_select(
$db,
$table,
$ids,
- $options
+ $options,
+ $result_type
) pg_select Function Availability
pg_select 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 |