PostgreSQL 函数
PHP 手册

pg_insert

(PHP 4 >= 4.3.0, PHP 5)

pg_insert 将数组插入到表中

说明

bool pg_insert ( resource $connection , string $table_name , array $assoc_array [, int $options ] )

pg_insert()assoc_array 数组中的值插入到由 table_name 指定的表中。table_name 中的列必须至少要有 assoc_array 中的单元那么多。table_name 中的字段名以及字段值必须和 assoc_array 中的键名及值匹配。如果成功则返回 TRUE,失败则返回 FALSE。如果给出了参数 options ,则函数 pg_convert() 会按照给定选项被作用到 assoc_array 上。

Example #1 pg_insert() 例子

<?php
    $db 
pg_connect ('dbname=foo');
    
// This is safe, since $_POST is converted automatically
    
$res pg_insert($db'post_log'$_POST);
    if (
$res) {
        echo 
"POST data is succesfully logged\n";
    }
    else {
        echo 
"User must have sent wrong inputs\n";
    }
?>

Warning

本函数是实验性的。本函数的行为,包括函数名称以及其它任何关于本函数的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本函数风险自担。

参见 pg_convert()


PostgreSQL 函数
PHP 手册