PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<pg_hostpg_last_error>
Last updated: Mon, 16 Jul 2012

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 上。

例子 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";
   }
?>

警告

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

参见 pg_convert()




<pg_hostpg_last_error>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST