Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: pg_put_line - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<pg_preparepg_query_params" width="11" height="7"/>
view the version of this page
Last updated: Sun, 07 May 2006

pg_put_line

(PHP 4 >= 4.0.3, PHP 5)

pg_put_line -- NULL で終わる文字列を PostgreSQL バックエンドに送信する

説明

bool pg_put_line ( string data )

bool pg_put_line ( resource connection, string data )

pg_put_line() は、NULL で終わる文字列を PostgreSQL バックエンドサーバに送信します。これは、PostgreSQL の COPY FROM コマンドとともに使用する場合に必要となります。

COPY は、PostgreSQL によってサポートされている 高速なデータ読み込みインターフェースです。データの内容はパースされず、 一度のトランザクションで実行されます。

低レベルな pg_put_line() コマンドを用いない別の方法は、 pg_copy_from() を使用することです。これは、はるかに シンプルなインターフェースです。

注意: pg_end_copy() を実行する際には、送信データの最後に 明示的に "\." の 2 文字を送信する必要があります。これによって、 バックエンドに対してデータ送信の終了を通知します。

警告

pg_put_line() の使用は、pg_lo_read()pg_lo_tell() などを含むラージオブジェクトの操作を 発生させ、これが失敗することもあります。そのような場合、かわりに pg_copy_from() および pg_copy_to() が使用可能です。

パラメータ

connection

PostgreSQL データベース接続リソース。connection が指定されていない場合はデフォルトの接続が使用されます。 デフォルトの接続は、直近の pg_connect() あるいは pg_pconnect() によって作成されたものです。

data

PostgreSQL バックエンドに直接送信されるテキストデータ。 最後に NULL が自動的に付加されます。

返り値

成功した場合に TRUE を、失敗した場合に FALSE を返します。

例 1. pg_put_line() の例

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



add a note add a note User Contributed Notes
pg_put_line
kurt at nospam dot milliganshome dot net
23-Aug-2005 01:08
This is the function you need if you are running into the infamous "must be superuser to COPY to or from a file" error from postgres.

<pg_preparepg_query_params" width="11" height="7"/>
 Last updated: Sun, 07 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Wed Jun 28 13:19:26 2006 JST