Home > PHP > Function > PostgreSQL > pg_convert()

pg_convert()

pg_convert - Convert associative array values into suitable for SQL statement

Syntax

array pg_convert (resource $connection, string $table_name, array $assoc_array, int $options)

Arguments

  • connection - PostgreSQL database connection resource.
  • table_name - Name of the table against which to convert types.
  • assoc_array - Data to be converted.
  • options - Any number of PGSQL_CONV_IGNORE_DEFAULT, PGSQL_CONV_FORCE_NULL or PGSQL_CONV_IGNORE_NOT_NULL, combined.

Description

pg_convert() checks and converts the values in assoc_array into suitable values for use in a SQL statement. Precondition for pg_convert() is the existence of a table table_name which has at least as many columns as assoc_array has elements. The fieldnames in table_name must match the indices in assoc_array and the corresponding datatypes must be compatible. Returns an array with the converted values on success, FALSE otherwise.

Version

PHP 4.3.0, 5

Return value

An array of converted values, or FALSE on error.