PHP.nl

pg_convert

pg_convert

Convert associative array values into forms suitable for SQL statements

 **pg_convert** PgSql\Connection $connection string $table_name array $values int $flags
checks and converts the values in
into suitable values for use in an SQL

statement. Precondition for is the existence of a table which has at least as many columns as has elements. The fieldnames in must match the indices in and the corresponding datatypes must be compatible. Returns an array with the converted values on success, false otherwise. pg_convert``values``pg_convert``table_name``values``table_name``values

Opmerking: > Boolean values are accepted and converted to PostgreSQL booleans. String representations of boolean values are also supported. null is converted to PostgreSQL NULL.

connection``table_nameName of the table against which to convert types.

valuesData to be converted.

flags Any number of , or , combined. PGSQL_CONV_IGNORE_DEFAULT``PGSQL_CONV_FORCE_NULL``PGSQL_CONV_IGNORE_NOT_NULL

An of converted values, return.falseforfailure. array

A or is thrown when the value or type of field does not match properly with a PostgreSQL's type. ValueError``TypeError

Voorbeeld: 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);
?>

pg_meta_data``pg_insert``pg_select``pg_update``pg_delete