(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
pg_convert — 將關(guān)聯(lián)的數(shù)組值轉(zhuǎn)換為適合 SQL 語(yǔ)句的格式。
$connection
,$table_name
,$assoc_array
,$options
= 0
pg_convert() 檢查 assoc_array
中的值并將其轉(zhuǎn)換為為適用于 SQL 語(yǔ)句的值。pg_convert()
的前提條件是現(xiàn)有的表 table_name
中具有的列至少有 assoc_array
中的單元那么多。table_name
中的字段名以及字段值必須和 assoc_array
中的鍵名及值匹配。如果成功則返回一個(gè)包括轉(zhuǎn)換后的值的數(shù)組,否則返回 false
。
注意:
If there are boolean fields in
table_name
don't use the constanttrue
inassoc_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.
此函數(shù)是實(shí)驗(yàn)性的。此函數(shù)的表象,包括名稱及其相關(guān)文檔都可能在未來(lái)的 PHP 發(fā)布版本中未通知就被修改。使用本函數(shù)風(fēng)險(xiǎn)自擔(dān)。
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.
An array of converted values, or false
on error.
示例 #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);
?>