1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-30 02:52:08 +02:00
Files
archived-doc-ja/reference/pgsql/reference.xml
Yu Watanabe 95924e7efd sync to en tree.
git-svn-id: https://svn.php.net/repository/phpdoc/ja/trunk@133223 c90b9560-bf6c-de11-be94-00142212c4b1
2003-06-25 09:51:34 +00:00

339 lines
12 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.6 $ -->
<!-- sync: 1.15 -->
<reference id="ref.pgsql">
<title>PostgreSQL 関数</title>
<titleabbrev>PostgreSQL</titleabbrev>
<partintro>
<section id="pgsql.intro">
&reftitle.intro;
<para>
PostgreSQLデータベースはオープンソースのプロダクツであり、無料で
使用可能できます。Postgresは元々UCB(カリフォルニア大学バークレイ校)
コンピュータ・サイエンス学部で開発されたものです。このPostgresは、
現在、いくつかの商用データベースにおいてサポートされつつあるオブジェク
トリレーショナルデータベース的概念の多くの先駆けでした。
Postgresは、SQL92/SQL3言語サポート、トランザクションインテグリティ、
拡張可能な型を提供しています。PostgreSQLは、Postgresのオリジナルの
バークレイ・コードのオープンソースの子孫にあたります。
</para>
</section>
<section id="pgsql.requirements">
&reftitle.required;
<para>
PostgreSQLサポートを使用するには、PostgreSQL 6.5以降が必要です。
PostgreSQL 7.0以降ではPostgreSQLモジュールの全ての機能を使用可能
です。PostgreSQLは、マルチバイト文字エンコーディングを含む多くの
文字エンコーディングをサポートしています。現在のバージョン及び
PostgreSQLに関するより詳細な情報は、
<ulink url="&url.pgsql;">&url.pgsql;</ulink>
<ulink url="&url.pgsql.techdocs;">&url.pgsql.techdocs;</ulink>
で入手可能です。
</para>
</section>
&reference.pgsql.configure;
&reference.pgsql.ini;
<section id="pgsql.using">
<title>使用法およびヒント</title>
<warning>
<para>
通知メッセージを処理するコードにバグがあるため、PHP 4.0.6で
PostgreSQLモジュールを使用することは推奨されません。
4.1.0以降を使用してください。
</para>
</warning>
<warning>
<para>
PostgreSQLモジュールの関数名は、現在のコーディング標準に準拠する
ために 4.2.0以降変更されます。新しい関数名の多くには、
pg_lo_open()のようにアンダースコアが付きます。
いくつかの関数は、pg_exec()からpg_query()というように、統一を
とるために関数名が変更されます。
古い名前も4.2.0とそれに続くいくつかのバージョンで使用可能ですが、
将来的には削除される可能性があります。
</para>
<table>
<title>変更された関数名</title>
<tgroup cols="2">
<thead>
<row>
<entry>古い関数名</entry>
<entry>新しい関数名</entry>
</row>
</thead>
<tbody>
<row>
<entry><function>pg_exec</function></entry>
<entry><function>pg_query</function></entry>
</row>
<row>
<entry><function>pg_getlastoid</function></entry>
<entry><function>pg_last_oid</function></entry>
</row>
<row>
<entry><function>pg_cmdtuples</function></entry>
<entry><function>pg_affected_rows</function></entry>
</row>
<row>
<entry><function>pg_numrows</function></entry>
<entry><function>pg_num_rows</function></entry>
</row>
<row>
<entry><function>pg_numfields</function></entry>
<entry><function>pg_num_fields</function></entry>
</row>
<row>
<entry><function>pg_fieldname</function></entry>
<entry><function>pg_field_name</function></entry>
</row>
<row>
<entry><function>pg_fieldsize</function></entry>
<entry><function>pg_field_size</function></entry>
</row>
<row>
<entry><function>pg_fieldnum</function></entry>
<entry><function>pg_field_num</function></entry>
</row>
<row>
<entry><function>pg_fieldprtlen</function></entry>
<entry><function>pg_field_prtlen</function></entry>
</row>
<row>
<entry><function>pg_fieldisnull</function></entry>
<entry><function>pg_field_is_null</function></entry>
</row>
<row>
<entry><function>pg_freeresult</function></entry>
<entry><function>pg_free_result</function></entry>
</row>
<row>
<entry><function>pg_result</function></entry>
<entry><function>pg_fetch_result</function></entry>
</row>
<row>
<entry><function>pg_loreadall</function></entry>
<entry><function>pg_lo_read_all</function></entry>
</row>
<row>
<entry><function>pg_locreate</function></entry>
<entry><function>pg_lo_create</function></entry>
</row>
<row>
<entry><function>pg_lounlink</function></entry>
<entry><function>pg_lo_unlink</function></entry>
</row>
<row>
<entry><function>pg_loopen</function></entry>
<entry><function>pg_lo_open</function></entry>
</row>
<row>
<entry><function>pg_loclose</function></entry>
<entry><function>pg_lo_close</function></entry>
</row>
<row>
<entry><function>pg_loread</function></entry>
<entry><function>pg_lo_read</function></entry>
</row>
<row>
<entry><function>pg_lowrite</function></entry>
<entry><function>pg_lo_write</function></entry>
</row>
<row>
<entry><function>pg_loimport</function></entry>
<entry><function>pg_lo_import</function></entry>
</row>
<row>
<entry><function>pg_loexport</function></entry>
<entry><function>pg_lo_export</function></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
従来の<function>pg_connect()</function>/<function>pg_pconnect()</function>
構文は、将来的に非同期接続
機能をサポートするために過去のものとなる可能性があります。
<function>pg_connect</function><function>pg_pconnect</function>
では、接続文字列を使用してください。
</para>
</warning>
<para>
全ての関数が全ての構築環境でサポートされるわけではありません。サ
ポートされる関数は、使用するlibpq(PostgreSQLのCクライアントインター
フェイス)のバージョンとlibpqのコンパイル方法に依存します。足りな
い関数がある場合、libpqはその関数を必要とする機能をサポートしませ
ん。
</para>
<para>
接続するPostgreSQLサーバーよりも新しいlibpqを使用することも重要で
す。使用するlibpqのバージョンがPostgreSQLサーバが期待するよりも古
い場合、問題を生じる可能性があります。
</para>
<para>
バージョン6.3(1998/3/2)以降、PostgreSQLはUNIXドメインソケットを
使用しています。これらの新しいコネクションの使用例を以下に示す表に
示します。このソケットは<filename>/tmp/.s.PGSQL.5432</filename>
あります。このオプションは<command>postmaster</command>に対して'-
i'フラグを指定することで有効となります。これは "Unixドメインソケッ
ト以外のTCP/IPソケットもlisten する"という意味です。
<table>
<title>postmasterとPHP</title>
<tgroup cols="3">
<thead>
<row>
<entry>postmaster</entry>
<entry>PHP</entry>
<entry>ステータス</entry>
</row>
</thead>
<tbody>
<row>
<entry>postmaster &amp;</entry>
<entry>pg_connect("dbname=MyDbName");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster -i &amp;</entry>
<entry>pg_connect("dbname=MyDbName");</entry>
<entry>OK</entry>
</row>
<row>
<entry>postmaster &amp;</entry>
<entry>pg_connect("host=localhost dbname=MyDbName");</entry>
<entry>
Unable to connect to PostgreSQL server: connectDB() failed:
Is the postmaster running and accepting TCP/IP (with -i)
connection at 'localhost' on port '5432'? in
/path/to/file.php3 on line 20.
</entry>
</row>
<row>
<entry>postmaster -i &amp;</entry>
<entry>pg_connect("host=localhost dbname=MyDbName");</entry>
<entry>OK</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<para>
PostgreSQL サーバへの接続は、以下のようにコマンド文字列の中に
値の組を羅列することにより、確立することができます。
<command>$conn = pg_Connect("host=myHost port=myPort tty=myTTY
options=myOptions dbname=myDB user=myUser password=myPassword");
</command>
</para>
<para>
以前の構文:
<command>
$conn = pg_connect ("host", "port", "options", "tty", "dbname")
</command>
は古い構文であり、推奨されません。
</para>
<para>
環境変数は、PostgreSQLサーバ/クライアントの動作に影響を与えます。
例えば、PostgreSQLモジュールは、ホスト名が接続文字列で省略された場
合、環境変数PGHOSTを探します。サポートされる環境変数は、バージョン
毎に異なります。詳細は、PostgreSQLプログラマ用マニュアル(libpq -
環境変数)を参照下さい。
</para>
<para>
適切なユーザ用に環境変数が設定されていることを確認して下さい。
カレントのプロセスで利用可能な環境変数を確認するには、
<literal>$_ENV</literal> または <function>getenv</function>
を使用して下さい。
</para>
<example>
<title>デフォルトのパラメータを設定する</title>
<programlisting>
<![CDATA[
PGHOST=pgsql.example.com
PGPORT=7890
PGDATABASE=web-system
PGUSER=web-user
PGPASSWORD=secret
PGDATESTYLE=ISO
PGTZ=JST
PGCLIENTENCODING=EUC-JP
export PGHOST PGPORT PGDATABASE PGUSER PGPASSWORD PGDATESTYLE PGTZ PGCLIENTENCODING
]]>
</programlisting>
</example>
</section>
&reference.pgsql.constants;
<section id="pgsql.examples">
&reftitle.examples;
<para>
PostgreSQL 7.1.0から、textデータ型の最大サイズは1GBとなっています。
古いPostgreSQLのtextデータ型はブロックサイズ(デフォルトは8KB、最大
32KBをコンパイル時に定義可能)の制限を受けていました。
</para>
<para>
ラージオブジェクト(lo)インターフェースを使用するには、そのクエリーを
トランザクション・ブロックの中に入れてやる必要があります。
トランザクション・ブロックは<command>BEGIN</command>で始まり、
そのトランザクションが有効な場合は<command>COMMIT</command>または
<command>END</command>で終わります。トランザクションが失敗した場合、
そのトランザクションは<command>ROLLBACK</command>または
<command>ABORT</command>により閉じる必要があります。
<example>
<title>ラージオブジェクトの使用例</title>
<programlisting role="php">
<![CDATA[
<?php
$database = pg_connect ("dbname=jacarta");
pg_exec ($database, "begin");
$oid = pg_locreate ($database);
echo ("$oid\n");
$handle = pg_loopen ($database, $oid, "w");
echo ("$handle\n");
pg_lowrite ($handle, "large object data");
pg_loclose ($handle);
pg_exec ($database, "commit");
?>
]]>
</programlisting>
</example>
ラージオブジェクトリソースを閉じる前にPostgreSQLサーバへの接続を
閉じないようにして下さい。
</para>
</section>
</partintro>
&reference.pgsql.functions;
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->