PHP Unconference Europe 2015

pg_convert

(PHP 4 >= 4.3.0, PHP 5)

pg_convert Converte i valori di un array associativo in una forma compatibile con i comandi SQL.

Descrizione

array pg_convert ( resource $connessione , string $nometabella , array $arrayassoc [, int $opzioni ] )

pg_convert() controlla e converte arrayassoc rendendolo compatibile con i comandi SQL.

Nota:

Questa funzione รจ sperimentale.

Vedere anche pg_meta_data()

add a note add a note

User Contributed Notes 4 notes

up
1
Anonymous
10 years ago
The only options that I see are:

PGSQL_CONV_IGNORE_DEFAULT  - Do not use DEAFULT value by removing field from returned array
PGSQL_CONV_FORCE_NULL - Convert to NULL if string is null string
PGSQL_CONV_IGNORE_NOT_NULL  - Ignore NOT NULL constraints

These are constants, so don't quote them or anything.
up
1
dharana at dharana dot net
11 years ago
I've found "options" possible values:

PG_CONV_CHECK - check only
PG_CONV_STRICT - raise warning for non fatal error
PG_CONV_QUOTE - add quote around values for vchar, text datetime.
PG_CONV_SLASH - add slashes if it needed.
PG_CONV_NULLCHK - check values are defined for NOT NULL fields.
PG_CONV_NO_DEFAULT - ignore default value even if value is empty string.
up
0
gorhas at gmail dot com
23 days ago
There is a problem when using interval.
If in the array
"time_pause" => '00:30:00'
and time_pause is an interval
the insert fails
pg_insert(): '00:30:00' does not match with  '^(@?[ \t]+)?((([-+]?[ \t]+)?[0-9]+(\.[0-9]*)?[ ...
up
-1
Andrew Falanga
9 years ago
Why does this function, pg_convert(), reject the string 'TRUE' as a valid value for the boolean types?  I'm using PHP 4.3.9 and my web page originally set the value for submission to update, to 'TRUE'.  pg_convert() threw it back to me saying that it's not a valid value for boolean types.  However, the postgresql website says otherwise.  See http://www.postgresql.org/docs/7.4/static/datatype-boolean.html for the context of my question/comment.
To Top