PHP 手冊
前一頁 |  | 下一頁

# pg_put_line

(PHP 4 >= 4.0.3, PHP 5)

pg_put_line -- Send a NULL-terminated string to PostgreSQL backend

## Description

bool pg_put_line ( string data )
bool pg_put_line ( resource connection, string data )

pg_put_line() sends a NULL-terminated string to the PostgreSQL backend server. This is useful for example for very high-speed inserting of data into a table, initiated by starting a PostgreSQL copy-operation. That final NULL-character is added automatically. 成功回傳`TRUE`失敗回傳`FALSE`。

> 注: The application must explicitly send the two characters "\." on the last line to indicate to the backend that it has finished sending its data.

範例 1. High-speed insertion of data into a table

`<?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); ?>`

警告
Use of the pg_put_line() causes most large object operations, including pg_lo_read() and pg_lo_tell(), to subsequently fail. You can use pg_copy_from() and pg_copy_to() instead.

See also pg_end_copy().

前一頁 | 內容 | 下一頁
pg_port | 上一層 | pg_query