pg_insert
(PHP 4 >= 4.3.0, PHP 5)
pg_insert — 将数组插入到表中
说明
mixed pg_insert
( resource $connection
, string $table_name
, array $assoc_array
[, int $options = PGSQL_DML_EXEC
] )
     pg_insert() 将 assoc_array 数组中的值插入到由
     table_name 指定的表中。
     如果给出了参数
     options ,则函数 pg_convert()
     会按照给定选项被作用到 assoc_array 上
    
Warning
此函数是实验性的。此函数的表象,包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。
参数
connection
      
PostgreSQL database connection resource.
table_name
      
       Name of the table into which to insert rows.  table_name
中的列必须至少要有 assoc_array
中的单元那么多。
      
assoc_array
      table_name 中的字段名以及字段值必须和 array 参数 中的键名及值匹配。
options
      
       Any number of PGSQL_CONV_OPTS,
       PGSQL_DML_NO_CONV,
       PGSQL_DML_EXEC,
       PGSQL_DML_ASYNC or
       PGSQL_DML_STRING combined. If PGSQL_DML_STRING is part of the
       options then query string is returned.
      
返回值
   成功时返回 TRUE, 或者在失败时返回 FALSE。  Returns string if PGSQL_DML_STRING is passed
   via options.
  
范例
Example #1 pg_insert() example
<?php
$dbconn = pg_connect('dbname=foo');
// This is safe, since $_POST is converted automatically
$res = pg_insert($dbconn, 'post_log', $_POST);
if ($res) {
echo "POST data is successfully loggedn";
} else {
echo "User must have sent wrong inputsn";
}
?>
参见
pg_convert() - 将关联的数组值转换为适合 SQL 语句的格式。