pg_insert
Insert array into table.
pg_insert Function synopsis
pg_insert(
PgSql\Connection $connection,
string $table_name,
array $values,
int $flags = PGSQL_DML_EXEC
): PgSql\Result|string|bool
Parameters
$connection
TypePgSql\Connection
$table_name
Typestring
Name of the table into which to insert rows. The table $table_name must at least
have as many columns as $values has elements.
$values
Typearray
An array whose keys are field names in the table $table_name,
and whose values are the values of those fields that are to be inserted.
$flags
OptionalTypeintDefault valuePGSQL_DML_EXEC
Any number of PGSQL_CONV_OPTS,
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 query string is returned. When PGSQL_DML_NO_CONV
or PGSQL_DML_ESCAPE is set, it does not call pg_convert internally.
Return value
TypePgSql\Result|string|bool
Returns true on success, false on failure. Or returns a string on success if PGSQL_DML_STRING is passed
via $flags.
Changes to the pg_insert Function
PHP 8.1
- Return type added:
PgSql\Result|string|bool - Parameter type added for parameter #1 (
$connection):PgSql\Connection
pg_insert(
- $connection,
+ PgSql\Connection $connection,
string $table_name,
array $values,
int $flags = PGSQL_DML_EXEC
- )
+ ): PgSql\Result|string|bool PHP 8.0
- 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 type added for parameter #3 (
$values):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
pg_insert(
- $db,
+ $connection,
- $table,
+ string $table_name,
- $values,
+ array $values,
- $options
+ int $flags = PGSQL_DML_EXEC
) pg_insert Function Availability
pg_insert 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 |