downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  

<pg_connection_statuspg_copy_from>
Last updated: Thu, 26 Jun 2008

pg_convert

(PHP 4 >= 4.3.0, PHP 5)

pg_convert — Convert associative array values into suitable for SQL statement

Description

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

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.

Note: If there are boolean fields in table_name don't use the constant TRUE in assoc_array . It will be converted to the string 'TRUE' which is no valid entry for boolean fields in PostgreSQL. Use one of t, true, 1, y, yes instead.

Warning

This function is EXPERIMENTAL. The behaviour of this function, its name, and surrounding documentation may change without notice in a future release of PHP. This function should be used at your own risk.

Parameters

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.

Return Values

An array of converted values, or FALSE on error.

Examples

Example #1 pg_convert() example

<?php
  $dbconn
= pg_connect('dbname=foo');
 
 
$tmp = array(
    
'author' => 'Joe Thackery',
    
'year' => 2005,
    
'title' => 'My Life, by Joe Thackery'
 
);
 
 
$vals = pg_convert($dbconn, 'authors', $tmp);
?>

See Also



add a noteadd a note User Contributed Notes
Convert associative array values into suitable for SQL statement
There are no user contributed notes for this page.




<pg_connection_statuspg_copy_from>
Last updated: Thu, 26 Jun 2008
show source | credits | sitemap | contact | advertising | mirror sites
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://phpbuilder.com/
Last updated: Tue Nov 1 20:20:59 2005 EST
Columns / Articles | Tips / Quickies | News | News Linking and RSS Feeds | Shared Code Library
Mail Archives | Support / Discussion Forums | Get Started! Links | Contribute! | Docs