PHP.nl

pg_copy_from

pg_copy_from

Insert records into a table from an array

bool **pg_copy_from** PgSql\Connection $connection string $table_name  $rows string $separator string $null_as
inserts records into a table from 

. It issues a SQL command internally to insert records. pg_copy_from``rows``COPY FROM

connection``table_name Name of the table into which to copy the . rows

rows An data to be copied into . Each value in becomes a row in . Each value in should be a delimited string of the values to insert into each field. Values should be linefeed terminated. iterable``table_name``rows``table_name``rows

separator The token that separates values for each field in each element of . Default is . rows``\t

null_as How SQL values are represented in the . Default is (). NULL``rows``\\N``"\\\\N"

return.success

Voorbeeld: example

<?php
   $db = pg_connect("dbname=publisher") or die("Could not connect");
   
   $rows = pg_copy_to($db, $table_name);
   
   pg_query($db, "DELETE FROM $table_name");
   
   pg_copy_from($db, $table_name, $rows);
?>

pg_copy_to