Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: pg_convert - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net

search for in the

pg_copy_from" width="11" height="7"/> <pg_connection_status
Last updated: Wed, 01 Nov 2006
view this page in

pg_convert

(PHP 4 >= 4.3.0, PHP 5)

pg_convert --  連想配列の値を、SQL 文として実行可能な形式に変換する

説明

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

pg_convert() は、assoc_array の中の値をチェックし、SQL 文の中で使用可能な形式に変換します。 少なくとも assoc_array の要素数以上のカラムを持つ テーブル table_name が存在することが前提条件と なります。assoc_array の要素名が table_name のフィールド名と一致し、また 要素に対応する値はフィールドのデータ型と互換性がなければなりません。 成功した場合に変換後の値の配列、それ以外の場合に FALSE を返します。

注意: 論理型のフィールドが table_name にあった場合、 対応する assoc_array では定数 TRUE を使用 しないでください。これは文字列 'TRUE' に変換されてしまい、PostgreSQL では論理型として無効な形式になります。代わりに t、true、1、y、yes のうちのひとつを用いてください。

警告

この関数は、 実験的 なものです。この関数の動作・ 名前・その他ドキュメントに書かれている事項は、予告なく、将来的な PHP のリリースにおいて変更される可能性があります。 この関数は自己責任で使用してください。

パラメータ

connection

PostgreSQL データベースの接続リソース。

table_name

変換対象となるテーブルの名前。

assoc_array

変換されるデータ。

options

PGSQL_CONV_IGNORE_DEFAULT, PGSQL_CONV_FORCE_NULL あるいは PGSQL_CONV_IGNORE_NOT_NULL の組み合わせ。

返り値

変換された値の配列を返します。エラー時には FALSE を返します。

例 1. pg_convert() の例

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



add a note add a note User Contributed Notes
pg_convert
Andrew Falanga
25-Feb-2005 05:03
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.
01-Apr-2004 01:02
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.
dharana at dharana dot net
12-May-2003 10:28
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.

 
show source | credits | sitemap | contact | advertising | mirror sites