pg_put_line

(PHP 4 >= 4.0.3, PHP 5)

pg_put_line -- 向 PostgreSQL 後端傳送以 NULL 結尾的字串

說明

bool pg_put_line ( [resource connection, string data] )

pg_put_line() 向 PostgreSQL 後端伺服器傳送以 NULL 結尾的字串。例如可以通過 PostgreSQL 的 copy 動作來向表中高速插入資料。結尾的 NULL 字元會自動加入。若果成功則返回 TRUE,失敗則返回 FALSE

注: 套用程式必須明確地在最後一行傳送兩個字元 "\." 來向後端指明傳送資料結束。

例子 1. 向表中高速插入資料

<?php 
    $conn 
pg_pconnect ("dbname=foo");
    
pg_query($conn"create table bar (a int4, b char(16), d float8)");
    
pg_query($conn"copy bar from stdin");
    
pg_put_line($conn"3\thello world\t4.5\n");
    
pg_put_line($conn"4\tgoodbye world\t7.11\n");
    
pg_put_line($conn"\\.\n");
    
pg_end_copy($conn);
?>