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.
pg_convert
説明
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 の組み合わせ。
pg_convert
25-Feb-2005 05:03
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.
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.