(PHP 4 >= 4.3.0, PHP 5, PHP 7)
pg_convert — Convert associative array values into forms suitable for SQL statements
$options= 0 ] ) : array
pg_convert() checks and converts the values in
assoc_array into suitable values for use in an 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
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,
Since PHP 5.6.0, it accepts boolean values, converting them to PostgreSQL booleans. String representations of boolean values are also supported.
NULLis converted to PostgreSQL NULL.
Prior to PHP 5.6.0, if there are boolean fields in
table_namedon't use the constant
assoc_array. It will be converted to the string 'TRUE' which is not a valid entry for boolean fields in PostgreSQL. Use one of "t", "true", 1, "y", "yes" instead.
PostgreSQL database connection resource.
Name of the table against which to convert types.
Data to be converted.
Any number of
An array of converted values, or
FALSE on error.
Example #1 pg_convert() example
$dbconn = pg_connect('dbname=foo');
$tmp = array(
'author' => 'Joe Thackery',
'year' => 2005,
'title' => 'My Life, by Joe Thackery'
$vals = pg_convert($dbconn, 'authors', $tmp);
|5.6.0||No longer experimental. Boolean/NULL data types are supported. Unknown/unsupported data types are escaped without validation. pg_convert() can be used with any data types.|