pg_insert

(PHP 4 >= 4.3.0, PHP 5, PHP 7)

pg_insert 锟斤拷锟斤拷锟斤拷锟斤拷氲斤拷锟斤拷锟�

说锟斤拷

pg_insert ( resource $connection , string $table_name , array $assoc_array [, int $options = PGSQL_DML_EXEC ] ) : mixed

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 logged\n";
  } else {
      echo 
"User must have sent wrong inputs\n";
  }
?>

锟轿硷拷

  • pg_convert() - 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷值转锟斤拷为锟绞猴拷 SQL 锟斤拷锟侥革拷式锟斤拷