cvs: peardoc /ja Translators bookinfo.xml language-defs.ent language-snippets.ent preface.xml /ja/chapters intro.xml parts.xml standards.xml
/ja/core db.xml http.xml log.xml mail.xml pear.xml

From: Date: Fri, 01 Feb 2002 14:37:25 +0000
Subject: cvs: peardoc /ja Translators bookinfo.xml language-defs.ent language-snippets.ent preface.xml /ja/chapters intro.xml parts.xml standards.xml
/ja/core db.xml http.xml log.xml mail.xml pear.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2269@lists.php.net to get a copy of this message
hirokawa Fri Feb 1 09:37:25 2002 EDT Added files: /peardoc/ja Translators bookinfo.xml language-defs.ent language-snippets.ent preface.xml /peardoc/ja/chapters intro.xml parts.xml standards.xml /peardoc/ja/core db.xml http.xml log.xml mail.xml pear.xml Log: added core/*.xml

Index: peardoc/ja/bookinfo.xml +++ peardoc/ja/bookinfo.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <bookinfo id="bookinfo"> <authorgroup id="authors"> <author> <firstname>Martin</firstname><surname>Jansen</surname> </author> <author> <firstname>Tomas</firstname><surname>V.V. Cox</surname> </author> <author> <firstname>Alexander</firstname><surname>Merz</surname> </author> </authorgroup> <pubdate>&peardoc.build-date;</pubdate> <authorgroup id="editors"> <editor> <firstname>Martin</firstname><surname>Jansen</surname> </editor> </authorgroup> <copyright> <year>2001-2002</year> <holder>The PHP PEAR Group</holder> </copyright> <legalnotice id="copyright"> <title>著作権</title> <simpara> This manual is &copy; Copyright 2001-2002 by the PHP PEAR Group. このグループのメンバーのリストは、このマニュ アルの先頭ページにあります。 </simpara> <simpara> 本マニュアルは、the Free Software Foundation;により発行された the GNU General Public Licenseのバージョン2、もしくは、(任意のオプ ションとして)それ以降のバージョンに基づき配布することができます。 </simpara> </legalnotice> </bookinfo> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/language-defs.ent +++ peardoc/ja/language-defs.ent <!-- $Revision: 1.1 $ --> <!ENTITY PEARManual "PEARマニュアル"> <!ENTITY Date "日付:"> <!ENTITY AboutPEAR "PEARについて"> <!ENTITY LanguageReference "言語リファレンス"> <!ENTITY Features "機能"> <!ENTITY PEAR "PEAR: the PHP Extension and Application Repository"> <!ENTITY Packages "PEARパッケージ"> <!ENTITY Pecl "PECLパッケージ"> <!ENTITY Core "PEARコア コンポーネント"> <!ENTITY Contributing "PEARへの貢献"> Index: peardoc/ja/language-snippets.ent +++ peardoc/ja/language-snippets.ent <!-- $Revision: 1.1 $ --> <!ENTITY warn.experimental '<warning><simpara>このモジュールは、<emphasis>実験的</emphasis>なものです。これは、これらの関数の動作、関数名は、このドキュメントに書かれて事項と同様に告知なく将来的なPHPのリリースで変更される可能性があります。注意を喚起するとともに、このモジュールは使用者のリスクで使用して下さい。</simpara></warning>'> <!ENTITY warn.experimental.func '<warning><simpara>この関数は、 <emphasis>実験的</emphasis>なステータスにあります。これは、この関数の動作、関数名、ここで書かれていること全てがPHPの将来のバージョンで予告なく変更される可能性があることを意味します。注意を喚起するとともに自分のリスクでこの関数を使用して下さい。</simpara></warning>'> <!ENTITY tip.ob-capture '<tip><simpara>ブラウザに直接結果を出力する全てのものと同様に、<link linkend="ref.outcontrol">出力制御関数</link>を使用してこの関数の出力をキャプチャーし、<type>string</type>等に保存することが可能です。</simpara></tip>'> <!ENTITY return.success '成功した場合に<constant>TRUE</constant>、失敗した場合に<constant>FALSE</constant> を返します。'> <!ENTITY return.falseproblem '<warning><simpara>簡単なif文において、この関数はエラー時に&false;を返す可能性がありますが、&false;として評価された値を返す可能性もあります。この関数の返り値を調べるには<link linkend="language.operators.comparison">the === operator</link>を使用して下さい。</simpara></warning>'> <!ENTITY link.coding-standards 'PEAR<link linkend="standards">コード作成規約</link>'> Index: peardoc/ja/preface.xml +++ peardoc/ja/preface.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <preface id="preface"> <title>はじめに</title> <abstract> <simpara> <acronym>PEAR</acronym>は、PHP Extension and Application Repositoryです。 </simpara> </abstract> <sect1 id="about"> <title>このマニュアルについて</title> <para> 本マニュアルは、<ulink url="&url.docbook.xml;">DocBook XML DTD</ulink>を用いて<acronym>XML</acronym>で書かれ、 <ulink url="&url.dsssl;"><acronym>DSSSL</acronym></ulink> (Document Style and Semantics Specification Language)をフォーマッ トに使用しています。<acronym>HTML</acronym>バージョンのフォーマッ トに使用されたツールは、<ulink url="&url.jclark;">James Clark</ulink>により書かれた<ulink url="&url.jade;">Jade</ulink>と <ulink url="&url.nwalsh;">Norman Walsh</ulink>により書かれた <ulink url="&url.dbstyle;">The Modular DocBook Stylesheets</ulink> です。 </para> <para> 本マニュアルは、過去に行われたPHPドキュメント作成グループの偉大な 成果に基づいています。 </para> </sect1> </preface> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/chapters/intro.xml +++ peardoc/ja/chapters/intro.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <chapter id="introduction"> <title>はじめに</title> <simpara> PEAR は、1999/11/21 に生まれた <ulink url="&url.malinimg;">Malin Bakken</ulink>に捧げられています。(最初のPEARのコードは、彼女が生ま れたちょうど二時間後に書かれました。) </simpara> <sect1 id="pear-whatis"> <title>PEARとは?</title> <simpara> PEAR は、TeXの CTAN および Perlの CPANにヒントを得たPHP拡張および PHPライブラリのコード用のコードレポジトリです。 </simpara> <para> PEARの目的は次のようなものです。 <itemizedlist> <listitem> <simpara> ライブラリコードの作者に他の開発者とコードを共有するための確実 な手段を提供する </simpara> </listitem> <listitem> <simpara> PHPコミュニティにコードを共有するためのインフラを提供する </simpara> </listitem> <listitem> <simpara> 開発者が移植性の高い再使用可能なコードを書きやすくするために標 準を定義する </simpara> </listitem> <listitem> <simpara> コードの維持管理と配布のためのツールを提供する </simpara> </listitem> </itemizedlist> </para> </sect1> </chapter> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/chapters/parts.xml +++ peardoc/ja/chapters/parts.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <chapter id="parts"> <title>PEARの3つの構成要素</title> <simpara> PEARは3つの要素に分けられます。本章ではこれらの要素について説明しま す。 </simpara> <sect1 id="parts-core"> <title>コア(Core)</title> <simpara> PEARのコア部分には基本的なコードが含まれ、他の多くのパッケージはこ のコアに基づき拡張されたものとなっています。このため、コアには、高 レベルの一般的な使用に供するためのコードが含まれています。 </simpara> </sect1> <sect1 id="parts-extended"> <title>拡張(Extended)</title> <simpara> PEARの拡張部分には、&link.coding-standards;に基づくPHPで書かれた 一般的なパッケージまたはCで書かれたPHP拡張モジュールが含まれます。 </simpara> <para> 拡張部分のパッケージは、PEARインストールツールにより配布され、 &link.coding-standards;に対応している必要があります。 </para> </sect1> <sect1 id="parts-pecl"> <title>PECL</title> <simpara> PECLは、Cで書かれたPHP拡張モジュール用のレポジトリであり、 &link.coding-standards;には対応していません。 </simpara> <para> PECLは、PHPの拡張モジュールツリー用のレポジトリとなるよう設定され ており、PHPソースツリーからPEARに移動されているものです。 PEAR. </para> <para> PEARのインストールツールは、現在、PECLから自動的にパッケージをイン ストールすることはできません。以下にインストール方法を簡単に説明し ます。 </para> <para> <itemizedlist> <listitem> <simpara> pearからパッケージをダウンロードし、どこかで展開します。 新規構築ディレクトリに行き、以下のステップを行います。 </simpara> </listitem> <listitem> <simpara>phpize</simpara> </listitem> <listitem> <simpara>./configure</simpara> </listitem> <listitem> <simpara>make</simpara> </listitem> <listitem> <simpara>cp modules/module.so /usr/local/lib/php</simpara> </listitem> </itemizedlist> </para> <para> この手順において、<filename>module.so</filename>を置く場所は使用す るシステムにおいては異なっているかもしれません。(<filename>php.ini</filename> および<function>phpinfo</function>を確認して下さい。) モジュールを実際に使用するには、<filename>php.ini</filename>に extensionディレクティブを追加するか、PHPファイルの中で dl("module.so")としてロードして下さい。 </para> <para> この拡張モジュールをPHPバイナリにも直接コンパイルすることも可能で す。この場合、パッケージを(ソースディレクトリの)php4/extに展開する 必要があります。この新しいモジュールディレクトリの中でphpizeも実行 します。しかし、PHPのconfigureを行う前に、PHPソースの最上位のディ レクトリで<filename>./buildconf</filename>を行う必要があります。 ここで、他の全ての拡張モジュールと同様に新規拡張モジュールを有効に してconfigure/コンパイルできます。 </para> </sect1> </chapter> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/chapters/standards.xml +++ peardoc/ja/chapters/standards.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <chapter id="standards"> <title>標準コーディング規約</title> <note> <simpara> PEAR標準コーディング規約は、PEARの公式ディストリビューション(PHPと 共に配布されるかPHP PEARレポジトリからのダウンロードにより取得可能) に含まれるコードに適用されます。 </simpara> </note> <sect1 id="standards.indenting"> <title>インデント</title> <para> タブではなく、空白4つのインデントを使用して下さい。 PEARコードを編集するためにEmacsを使用する場合、indent-tabs-modeを nilに設定する必要があります。以下に、これらのガイドラインに基づき Emacsを設定するモードフックの例を示します。(PHPファイルを編集する 際にこれがコールされるようにする必要があります) <programlisting role="elisp"> <![CDATA[ (defun php-mode-hook () (setq tab-width 4 c-basic-offset 4 c-hanging-comment-ender-p nil indent-tabs-mode (not (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name)) (string-match "\.php$" (buffer-file-name)))))) ]]> </programlisting> </para> <para> 以下に同様なことを行うvimルールを示します。 <programlisting role="vim"> <![CDATA[ set expandtab set shiftwidth=4 set softtabstop=4 set tabstop=4 ]]> </programlisting> </para> </sect1> <sect1 id="standards.control"> <title>制御構造</title> <para> These include if, for, while, switch, etc. Here is an example if statement, since it is the most complicated of them: <programlisting role="php"> <![CDATA[ if ((condition1) || (condition2)) { action1; } elseif ((condition3) &amp;&amp; (condition4)) { action2; } else { defaultaction; } ]]> </programlisting> </para> <simpara> Control statements should have one space between the control keyword and opening parenthesis, to distinguish them from function calls. </simpara> <simpara> You are strongly encouraged to always use curly braces even in situations where they are technically optional. Having them increases readability and decreases the likelihood of logic errors being introduced when new lines are added. </simpara> <para> For switch statements: <programlisting role="php"> <![CDATA[ switch (condition) { case 1: action1; break; case 2: action2; break; default: defaultaction; break; } ]]> </programlisting> </para> </sect1> <sect1 id="standards.funcalls"> <title>関数コール</title> <para> Functions should be called with no spaces between the function name, the opening parenthesis, and the first parameter; spaces between commas and each parameter, and no space between the last parameter, the closing parenthesis, and the semicolon. Here's an example: <programlisting role="php"> <![CDATA[ $var = foo($bar, $baz, $quux); ]]> </programlisting> </para> <para> As displayed above, there should be one space on either side of an equals sign used to assign the return value of a function to a variable. In the case of a block of related assignments, more space may be inserted to promote readability: <programlisting role="php"> <![CDATA[ $short = foo($bar); $long_variable = foo($baz); ]]> </programlisting> </para> </sect1> <sect1 id="standards.funcdef"> <title>関数定義</title> <para> Function declarations follow the "one true brace" convention: <programlisting role="php"> <![CDATA[ function fooFunction($arg1, $arg2 = '') { if (condition) { statement; } return $val; } ]]> </programlisting> </para> <para> Arguments with default values go at the end of the argument list. Always attempt to return a meaningful value from a function if one is appropriate. Here is a slightly longer example: <programlisting role="php"> <![CDATA[ function connect(&amp;$dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &amp;$dsn; } else { $dsninfo = DB::parseDSN($dsn); } if (!$dsninfo || !$dsninfo['phptype']) { return $this->raiseError(); } return true; } ]]> </programlisting> </para> </sect1> <sect1 id="standards.comments"> <title>コメント</title> <para> Inline documentation for classes should follow the PHPDoc convention, similar to Javadoc. More information about PHPDoc can be found here: <ulink url="&url.phpdoc;">&url.phpdoc;</ulink> </para> <para> Non-documentation comments are strongly encouraged. A general rule of thumb is that if you look at a section of code and think "Wow, I don't want to try and describe that", you need to comment it before you forget how it works. </para> <para> C style comments (/* */) and standard C++ comments (//) are both fine. Use of Perl/shell style comments (#) is discouraged. </para> </sect1> <sect1 id="standards.including"> <title>コードの読み込み</title> <para> Anywhere you are unconditionally including a class file, use <function>require_once</function>. Anywhere you are conditionally including a class file (for example, factory methods), use <function>include_once</function>. Either of these will ensure that class files are included only once. They share the same file list, so you don't need to worry about mixing them - a file included with <function>require_once</function> will not be included again by <function>include_once</function>. <note> <simpara> <function>include_once</function> and <function>require_once</function> are statements, not functions. You don't <emphasis>need</emphasis> parentheses around the filename to be included. </simpara> </note> </para> </sect1> <sect1 id="standards.tags"> <title>PHPコードタグ</title> <para> <emphasis>Always</emphasis> use <literal>&lt;?php ?></literal> to delimit PHP code, not the <literal>&lt;? ?></literal> shorthand. This is required for PEAR compliance and is also the most portable way to include PHP code on differing operating systems and setups. </para> </sect1> <sect1 id="standards.header"> <title>ヘッダのコメントブロック</title> <para> All source code files in the core PEAR distribution should contain the following comment block as the header: <programlisting role="php"> <![CDATA[ /* vim: set expandtab tabstop=4 shiftwidth=4: */ // +----------------------------------------------------------------------+ // | PHP version 4.0 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Original Author <author@example.com> | // | Your Name <you@example.com> | // +----------------------------------------------------------------------+ // // $Id: standards.xml,v 1.1 2002/02/01 14:37:25 hirokawa Exp $ ]]> </programlisting> </para> <para> There's no hard rule to determine when a new code contributor should be added to the list of authors for a given source file. In general, their changes should fall into the "substantial" category (meaning somewhere around 10% to 20% of code changes). Exceptions could be made for rewriting functions or contributing new logic. </para> <para> Simple code reorganization or bug fixes would not justify the addition of a new individual to the list of authors. </para> <para> Files not in the core PEAR repository should have a similar block stating the copyright, the license, and the authors. All files should include the modeline comments to encourage consistency. </para> </sect1> <sect1 id="standards.cvs"> <title>CVSの使用</title> <simpara> This section applies only to packages using CVS at cvs.php.net. </simpara> <para> Include the &dollar;Id&dollar; CVS keyword in each file. As each file is edited, add this tag if it's not yet present (or replace existing forms such as "Last Modified:", etc.). <!-- <note> <simpara> We have a custom $Horde tag in Horde cvs to track our versions separately; we could do the same and make a $PEAR tag, that would remain even if PEAR files were put into another source control system, etc...] </simpara> </note> --> </para> <para> The rest of this section assumes that you have basic knowledge about CVS tags and branches. </para> <para> CVS tags are used to label which revisions of the files in your package belong to a given release. Below is a list of the required and suggested CVS tags: <variablelist> <varlistentry> <term>RELEASE_<replaceable>n_n</replaceable></term> <listitem> <simpara> (required) Used for tagging a release. If you don't use it, there's no way to go back and retrieve your package from the CVS server in the state it was in at the time of the release. </simpara> </listitem> </varlistentry> <varlistentry> <term>QA_<replaceable>n_n</replaceable></term> <listitem> <simpara> (branch, optional) If you feel you need to roll out a release candidate before releasing, it's a good idea to make a branch for it so you can isolate the release and apply only those critical fixes before the actual release. Meanwhile, normal development may continue on the main trunk. </simpara> </listitem> </varlistentry> <varlistentry> <term>MAINT_<replaceable>n_n</replaceable></term> <listitem> <simpara> (branch, optional) If you need to make "micro-releases" (for example 1.2.1 and so on after 1.2), you can use a branch for that too, if your main trunk is very active and you want only minor changes between your micro-releases. </simpara> </listitem> </varlistentry> </variablelist> Only the RELEASE tag is required, the rest are recommended for your convenience. </para> <para> Below is an example of how to tag the 1.2 release of the "Money_Fast" package: <informalexample> <screen><prompt>$ </prompt><command>cd pear/Money_Fast</command> <prompt>$ </prompt><command>cvs tag RELEASE_1_2</command> <computeroutput>T Fast.php T README T package.xml </computeroutput> </screen> </informalexample> By doing this you make it possible for the PEAR web site to take you through the rest of your release process. </para> <para> Here's an example of how to create a QA branch: <informalexample> <screen><prompt>$ </prompt><command>cvs tag QA_2_0_BP</command> ... <prompt>$ </prompt><command>cvs rtag -b -r QA_2_0_BP QA_2_0</command> <prompt>$ </prompt><command>cvs update -r QA_2_0</command> <prompt>$ </prompt><command>cvs tag RELEASE_2_0RC1</command> ...and then the actual release, from the same branch: <prompt>$ </prompt><command>cvs tag RELEASE_2_0</command> </screen> </informalexample> The "QA_2_0_BP" tag is a "branch point" tag, which is the start point of the tag. It's always a good idea to start a CVS branch from such branch points. MAINT branches may use the RELEASE tag as their branch point. </para> </sect1> <sect1 id="standards.exampleurls"> <title>URLの例</title> <para> Use "example.com" for all example URLs, per RFC 2606. </para> </sect1> <sect1 id="standards.naming"> <title>命名規約</title> <sect2> <title>クラス</title> <para> Classes should be given descriptive names. Avoid using abbreviations where possible. Class names should always begin with an uppercase letter. The PEAR class hierarchy is also reflected in the class name, each level of the hierarchy separated with a single underscore. Examples of good class names are: <informaltable> <tgroup cols="3"> <tbody> <row> <entry><simpara>Log</simpara></entry> <entry><simpara>Net_Finger</simpara></entry> <entry><simpara>HTML_Upload_Error</simpara></entry> </row> </tbody> </tgroup> </informaltable> </para> </sect2> <sect2> <title>関数とメソッド</title> <para> Functions and methods should be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). Functions should in addition have the package name as a prefix, to avoid name collisions between packages. The initial letter of the name (after the prefix) is lowercase, and each letter that starts a new "word" is capitalized. Some examples: <informaltable> <tgroup cols="4"> <tbody> <row> <entry><simpara>connect()</simpara></entry> <entry><simpara>getData()</simpara></entry> <entry><simpara>buildSomeWidget()</simpara></entry> <entry><simpara>XML_RPC_serializeData()</simpara></entry> </row> </tbody> </tgroup> </informaltable> </para> <para> Private class members (meaning class members that are intented to be used only from within the same class in which they are declared; PHP does not yet support truly-enforceable private namespaces) are preceded by a single underscore. For example: <informaltable> <tgroup cols="3"> <tbody> <row> <entry><simpara>_sort()</simpara></entry> <entry><simpara>_initTree()</simpara></entry> <entry><simpara>$this->_status</simpara></entry> </row> </tbody> </tgroup> </informaltable> </para> </sect2> <sect2> <title>定数</title> <para> Constants should always be all-uppercase, with underscores to separate words. Prefix constant names with the uppercased name of the class/package they are used in. For example, the constants used by the <literal>DB::</literal> package all begin with "<literal>DB_</literal>". </para> </sect2> <sect2> <title>グローバル変数</title> <para> If your package needs to define global variables, their name should start with a single underscore followed by the package name and another underscore. For example, the PEAR package uses a global variable called $_PEAR_destructor_object_list. </para> </sect2> </sect1> </chapter> <!-- 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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/core/db.xml +++ peardoc/ja/core/db.xml <?xml encoding="utf-8"?> <!-- $Id: db.xml,v 1.1 2002/02/01 14:37:25 hirokawa Exp $ --> <reference id="core.db"> <title>PEAR DB: SQLデータベースをアクセスするための統一API</title> <titleabbrev>PEAR DB</titleabbrev> <partintro> <simpara> 本章は、PEARデータベース抽象化レイヤの使用法を説明します。 </simpara> </partintro> <refentry id="core.db.tut_dsn"> <refnamediv> <refname>DSN</refname> <refpurpose>データソース名</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> PEAR::DBにより、データベースに接続するには、有効な <acronym>DSN - data source name</acronym>を作成する必要があります。 このDSNは、以下の要素からなります。 </simpara> <para> <simplelist> <member> <parameter>phptype</parameter>: PHPで使用されるデータベースバックエンド (すなわちmysql, odbc等) </member> <member> <parameter>dbsyntax</parameter>: SQL構文等のデータベース関連構文 </member> <member> <parameter>protocol</parameter>: 使用する通信プロトコル (すなわち、tcp, unix等) </member> <member> <parameter>hostspec</parameter>: ホスト指定 (hostname[:port]) </member> <member> <parameter>database</parameter>: DBMSサーバ上のデータベース使用方法 </member> <member> <parameter>username</parameter>: ログイン用ユーザ名 </member> <member> <parameter>password</parameter>: ログイン用のパスワード </member> <member> <parameter>proto_opts</parameter>: <parameter>protocol</parameter>で使用されるオプション </member> </simplelist> </para> <para> The format of the supplied DSN is in its fullest form: <programlisting role="url"> <![CDATA[ phptype(dbsyntax)://username:password@protocol+hostspec/database ]]> </programlisting> Most variations are allowed: <programlisting role="url"> <![CDATA[ phptype://username:password@protocol+hostspec:110//usr/db_file.db phptype://username:password@hostspec/database_name phptype://username:password@hostspec phptype://username@hostspec phptype://hostspec/database phptype://hostspec phptype(dbsyntax) phptype ]]> </programlisting> The currently supported database backends are: <programlisting role="configure"> <![CDATA[ mysql -> MySQL pgsql -> PostgreSQL ibase -> InterBase msql -> Mini SQL mssql -> Microsoft SQL Server oci8 -> Oracle 7/8/8i odbc -> ODBC (Open Database Connectivity) sybase -> SyBase ifx -> Informix fbsql -> FrontBase ]]> </programlisting> </para> <para> With an up-to-date version of <classname>DB</classname>, you can use a second DSN format <programlisting role="url"> <![CDATA[ phptype(syntax)://user:pass@protocol(proto_opts)/database example: Connect to database through a socket mysql://user@unix(/path/to/socket)/pear Connect to database on a non standard port pgsql://user:pass@word@tcp(localhost:5555)/pear ]]> </programlisting> </para> <para> <warning id="core.db.features.warning"> <title>重要!</title> <para> いくつかの機能は、全てのデータベースバックエンドでサポートされ ていません。どの機能がどのバックエンドでサポートされているかに 関する詳細なリストを取得するには、 <quote>&lt;pear base dir&gt;/DB/STATUS</quote>にあるPEAR DB拡張 のステータスドキュメントを参照して下さい。 </para> </warning> </para> </refsect1> </refentry> <refentry id="core.db.tut_connect"> <refnamediv> <refname>Connect</refname> <refpurpose>接続および接続の終了</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> To connect to a database you have to use the function <function>DB::connect</function>, which requires a valid <link linkend="core.db.dsn">DSN</link> as parameter and optional a boolean value, which determines wether to use a persistent connection or not. In case of success you get a new instance of the database class. It is strongly recommened to check this return value with <function>DB::isError</function>. To disconnect use the method <function>disconnect</function> from your database class instance. </simpara> <para> <programlisting role="php"> <![CDATA[ <?php require_once 'DB.php'; $user = 'foo'; $pass = 'bar'; $host = 'localhost'; $db_name = 'clients_db'; // Data Source Name: This is the universal connection string $dsn = "mysql://$user:$pass@$host/$db_name"; // DB::connect will return a PEAR DB object on success // or an PEAR DB Error object on error $db = DB::connect($dsn, true); // Alternatively: $db = DB::connect($dsn); // With DB::isError you can differentiate between an error or // a valid connection. if (DB::isError($db)) { die ($db->getMessage()); } .... // You can disconnect from the database with: $db->disconnect(); ?> ]]> </programlisting> </para> </refsect1> </refentry> <refentry id="core.db.tut_query"> <refnamediv> <refname>Query</refname> <refpurpose>データベースでクエリを実行する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> To perform a query against a database you have to use the function <function>query</function>, that takes the query string as an argument. On failure you get a DB Error object, check it with <function>DB::isError</function>. On succes you get <parameter>DB_OK</parameter> (predefined PEAR::DB constant) or when you set a <parameter>SELECT</parameter>-statment a DB Result object. </simpara> <para> <programlisting role="php"> <![CDATA[ <?php // Once you have a valid DB object... $sql = "select * from clients"; $result = $db->query($sql); // Always check that $result is not an error if (DB::isError($result)) { die ($result->getMessage()); } .... ?> ]]> </programlisting> </para> </refsect1> </refentry> <refentry id="core.db.tut_fetch"> <refnamediv> <refname>Fetch</refname> <refpurpose>クエリ結果からレコードを取得する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <refsect2> <title>fetch関数</title> <simpara> The <classname>DB_Result</classname> object provides two functions to fetch rows: <function>fetchRow</function> and <function>fetchInto</function>. <function>fetchRow</function> returns the row, null on no more data or a <classname>DB_Error</classname>, when an error occurs. <function>fetchInto</function> requires a variable, which be will directly assigned by reference to the result row. It will return null when result set is empty or a <classname>DB_Error</classname> too. </simpara> <para> <programlisting role="php"> <![CDATA[ <?php ... $db = DB::connect($dsn); $res = $db->query("select * from mytable"); // Get each row of data on each iteration until // there is no more rows while ($row = $result->fetchRow()) { $id = $row[0]; } // Or: // an example using fetchInto() while ($result->fetchInto($row)) { $id = $row[0]; } ?> ]]> </programlisting> </para> </refsect2> <refsect2> <title>レコードの取得形式を選択する</title> <para> サポートされる取得モードを以下に示します。 <itemizedlist> <listitem> <para> <parameter>DB_FETCHMODE_ORDERED</parameter> (default) </para> <para> The <function>fetch*</function> returns an ordered array. The order is taken from the select statment. <programlisting role="php"> <![CDATA[ <?php $res = $db->query('select id, name, email from users'); $row = $res->fetchRow(DB_FETCHMODE_ORDERED); /* $row will contain: array ( 0 => <column "id" data>, 1 => <column "name" data>, 2 => <column "email" data> ) */ // Access the data with: $id = $row[0]; $name = $row[1]; $email = $row[2]; ?> ]]> </programlisting> </para> </listitem> <listitem> <para> <parameter>DB_FETCHMODE_ASSOC</parameter> </para> <para> Returns an associative array with the column names as the array keys <programlisting role="php"> <![CDATA[ <?php $res = $db->query('select id, name, email from users'); $row = $res->fetchRow(DB_FETCHMODE_ASSOC); /* $row will contain: array ( 'id' => <column "id" data>, 'name' => <column "name" data>, 'email' => <column "email" data> ) */ // Access the data with: $id = $row['id']; $name = $row['name']; $email = $row['email']; ?> ]]> </programlisting> </para> </listitem> <listitem> <para> <parameter>DB_FETCHMODE_OBJECT</parameter> </para> <para> Returns a DB_row object with column names as properties <programlisting role="php"> <![CDATA[ <?php $res = $db->query('select id, name, email from users'); $row = $res->fetchRow(DB_FETCHMODE_OBJECT); /* $row will contain: db_row Object ( [id] => <column "id" data>, [name] => <column "name" data>, [email] => <column "email" data> ) */ // Access the data with: $id = $row->id; $name = $row->name; $email = $row->email; ?> ]]> </programlisting> </para> </listitem> </itemizedlist> </para> </refsect2> <refsect2> <title>取得するレコードの形式を設定する</title> <para> 各コール毎またはDBインスタンス全体で取得モードを設定することが可 能です。 <programlisting role="php"> <![CDATA[ <?php // 1) Set the mode per call: while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) { $id = $row['id']; } // 2) Set the mode for all calls: $db = DB::connect($dsn); // this will set a default fetchmode for this Pear DB instance // (for all queries) $db->setFetchMode(DB_FETCHMODE_ASSOC); $result = $db->query(...); while ($row = $result->fetchRow()) { $id = $row['id']; } ?> ]]> </programlisting> </para> </refsect2> <refsect2> <title>数字でレコードを取得する</title> <para> The PEAR DB fetch system also supports an extra parameter to the fetch statement. So you can fetch rows from a result by number. This is especially helpful if you only want to show sets of an entire result (for example in building paginated HTML lists), fetch rows in an special order, etc. <programlisting role="php"> <![CDATA[ <?php ... // the row to start fetching $from = 50; // how many results per page $res_per_page = 10; // the last row to fetch for this page $to = $from + $res_per_page; foreach (range($from, $to) as $rownum) { if (!$row = $res->fetchrow($fetchmode, $rownum)) { break; } $id = $row[0]; .... } ?> ]]> </programlisting> </para> </refsect2> <refsect2> <title>結果接とを解放する</title> <para> It is recommended to finish the result set after processing in order to to save memory. Use <function>free</function> to do this. <programlisting role="php"> <![CDATA[ <?php ... $result = $db->query('SELECT * FROM clients'); while ($row = $result->fetchRow()) { ... } $result->free(); ?> ]]> </programlisting> </para> </refsect2> <refsect2> <title>簡易的なデータ取得</title> <para> PEAR DB provides some special ways to retrieve information from a query without the need of using <function>fetch*</function> and loop throw results. </para> <para> <function>getOne</function> retrieves the first result of the first column from a query <programlisting role="php"> <![CDATA[ $numrows = $db->getOne('select count(id) from clients'); ]]> </programlisting> </para> <para> <function>getRow</function> returns the first row and return it as an array <programlisting role="php"> <![CDATA[ $sql = 'select name, address, phone from clients where id=1'; if (is_array($row = $db->getRow($sql))) { list($name, $address, $phone) = $row; } ]]> </programlisting> </para> <para> <function>getCol</function> returns an array with the data of the selected column. It accepts the column number to retrieve as the second param. <programlisting role="php"> <![CDATA[ $all_client_names = $db->getCol('select name from clients'); ]]> </programlisting> The above sentence could return for example: $all_client_names = array('Stig', 'Jon', 'Colin'); </para> <para> <function>getAssoc</function> fetches the entire result set of a query and return it as an associative array using the first column as the key. <programlisting role="php"> <![CDATA[ $data = getAssoc('SELECT name, surname, phone FROM mytable') /* Will return: array( 'Peter' => array('Smith', '944679408'), 'Tomas' => array('Cox', '944679408'), 'Richard' => array('Merz', '944679408') ) */ ]]> </programlisting> </para> <para> <function>getAll</function> fetches all the rows returned from a query <programlisting role="php"> <![CDATA[ $data = getAll('SELECT id, text, date FROM mytable'); /* Will return: array( 1 => array('4', 'four', '2004'), 2 => array('5', 'five', '2005'), 3 => array('6', 'six', '2006') ) */ ]]> </programlisting> </para> <para> The <function>get*</function> family methods will do all the dirty job for you, this is: launch the query, fetch the data and free the result. Please note that as all PEAR DB functions they will return a <classname>PEAR DB_error</classname> object on errors. </para> </refsect2> <refsect2> <title>Getting more information from query results</title> <para> With PEAR DB you have many ways to retrieve useful information from query results. These are: <itemizedlist> <listitem> <para> <function>numRows</function>: Returns the total number of rows returned from a "SELECT" query. <programlisting role="php"> <![CDATA[ // Number of rows echo $res->numRows(); ]]> </programlisting> </para> </listitem> <listitem> <para> <function>numCols</function>: Returns the total number of columns returned from a "SELECT" query. <programlisting role="php"> <![CDATA[ // Number of cols echo $res->numCols(); ]]> </programlisting> </para> </listitem> <listitem> <para> <function>affectedRows</function>: Returns the number of rows affected by a data manipulation query ("INSERT", "UPDATE" or "DELETE"). <programlisting role="php"> <![CDATA[ // remember that this statement won't return a result object $db->query('DELETE * FROM clients'); echo 'I have deleted ' . $db->affectedRows() . ' clients'; ]]> </programlisting> </para> </listitem> <listitem> <para> <function>tableInfo</function>: Returns an associative array with information about the returned fields from a "SELECT" query. <programlisting role="php"> <![CDATA[ // Table Info print_r($res->tableInfo()); ]]> </programlisting> </para> </listitem> </itemizedlist> Don't forget to check if the returned result from your action is a PEAR Error object. If you get a error message like <quote>DB_error: database not capable</quote>, that means that your database backend doesn't support this action. </para> </refsect2> </refsect1> </refentry> <refentry id="core.db.tut_sequences"> <refnamediv> <refname>シーケンス</refname> <refpurpose>データベース シーケンス</refpurpose> </refnamediv> <refsect1> <title>説明</title> <para> Sequences are a way of offering unique IDs for data rows. If you do most of you work with e.g. MySQL, think of sequences as another way of doing AUTO_INCREMENT. It's quite simple, first you request an ID, and then you insert that value in the ID field of the new row you're creating. You can have more than one sequence for all your tables, just be sure that you always use the same sequence for any particular table. To get the value of this unique ID use <function>nextId</function>, if a sequence doesn't exists, it will be created. <programlisting role="php"> <![CDATA[ <?php ... $id = $db->nextId('mySequence'); // Use the ID in your INSERT query $res = $db->query("INSERT INTO myTable (id,text) VALUES ($id,'foo')"); ... ?> ]]> </programlisting> </para> </refsect1> </refentry> <refentry id="core.db.tut_execute"> <refnamediv> <refname>execute</refname> <refpurpose>PrepareとExecute/ExecuteMultiple</refpurpose> </refnamediv> <refsect1> <title>説明</title> <refsect2> <title>目的</title> <para> <function>Prepare</function> and <function>execute*</function> give you more power and flexibilty for query execution. You can use them, if you have to do more than one equal query (i.e. adding a list of adresses to a database) or if you want to support different databases, which have different implementations of the SQL standard. </para> <para> Imagine you want to support two databases with different INSERT syntax: <programlisting role="php"> <![CDATA[ db1 : INSERT INTO tbl_name ( col1, col2 ... ) VALUES ( expr1, expr2 ... ) db2 : INSERT INTO tbl_name SET col1=expr1, col2=expr2 ... ]]> </programlisting> Correspondending to create multi-lingual scripts you can create a array with queries like this: <programlisting role="php"> <![CDATA[ $statment['db1']['INSERT_PERSON'] = "INSERT INTO person ( surname, name, age ) VALUES ( ?, ?, ? )" ; $statment['db2']['INSERT_PERSON'] = "INSERT INTO person SET surname=?, name=?, age=?" ; ]]> </programlisting> </para> </refsect2> <refsect2> <title>prepare</title> <para> To use the features give in <link linkend="core.db.prep_exec.purpose">Purpose</link> you have to do two steps. Step one is to <emphasis>prepare</emphasis> the statment and the second is to <emphasis>excute</emphasis> it. </para> <para> <function>Prepare</function> has to be called with the generic statment at least once. It returns a handle for the statment. </para> <para> To create a generic statment is simple. Write the SQL query as usual, i.e. <programlisting> <![CDATA[ SELECT surname, name, age FROM person WHERE name = 'name_to_find' AND age < 'age_limit' ]]> </programlisting> Now check which parameters should be replaced while script runtime. Substitute this parameters with a placeholder. <programlisting> <![CDATA[ SELECT surname, name, age FROM person WHERE name = ? AND age < ? ]]> </programlisting> So, thats all! Now you have a generic statement, required by <function>prepare</function>. </para> <para> <function>Prepare</function> can handle different types of placeholders or wildcards. <simplelist> <member> ? - (recommended) stands for a scalar value like strings or numbers, the value will be quoted depending of the database </member> <member> ! - stands for a scalar value and will inserted into the statement <quote>as is</quote>. </member> <member> & - requires an existing filename, the content of this file will be included into the statment (i.e. for saving binary data of a graphic file in a database) </member> </simplelist> </para> </refsect2> <refsect2> <title>execute/ executeMultiple</title> <para> After preparing the statement, you can excute the query. This means to assign the variables to the prepared statement. To do this, <function>execute</function> requires two arguments, the statement handle of <function>prepare</function> and an array with the values to assign. The array has to be numerically ordered. The first entry of the array represents the first wildcard, the second the second wildcard etc. The order is independent from the used wildcard char. <programlisting role="php"> <![CDATA[ <?php // Example inserting data $alldata = array( array(1, 'one', 'en'), array(2, 'two', 'to'), array(3, 'three', 'tre'), array(4, 'four', 'fire')); $sth = $dbh->prepare("INSERT INTO numbers VALUES(?,?,?)"); foreach ($alldata as $row) { $dbh->execute($sth, $row); } ?> ]]> </programlisting> In the example the query is done four times: <programlisting> <![CDATA[ INSERT INTO numbers VALUES( '1', 'one', 'en') INSERT INTO numbers VALUES( '2', 'two', 'to') INSERT INTO numbers VALUES( '3', 'three', 'tre') INSERT INTO numbers VALUES( '4', 'four', 'fire') ]]> </programlisting> <function>ExecuteMultiple</function> works in the same way, but requires a two dimensional array. So you can avoid the explicit foreach in the eample above. <programlisting role="php"> <![CDATA[ <?php // Example inserting data $alldata = array( array(1, 'one', 'en'), array(2, 'two', 'to'), array(3, 'three', 'tre'), array(4, 'four', 'fire')); $sth = $dbh->prepare("INSERT INTO numbers VALUES(?,?,?)"); $dbh->executeMultiple($sth, $alldata); } ?> ]]> </programlisting> The result is the same. If one of the records failed, the unfinished records will not be executed. </para> <para> If <function>execute*</function> fails a <classname>DB_Error</classname>, else a <parameter>DB_OK</parameter> will returned. </para> </refsect2> </refsect1> </refentry> <refentry id="core.db.connect"> <refnamediv> <refname>DB::connect()</refname> <refpurpose> 新規DB接続オブジェクトを作成し、指定したデータベースに接続する </refpurpose> </refnamediv> <refsect1 id="core.db.connect.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>connect</function></funcdef> <paramdef>string <parameter>$dsn</parameter></paramdef> <paramdef>array <parameter><optional>$options</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$dsn</parameter> - <parameter>data source name</parameter> See the <link linkend="core.db.tut_dsn">"DSN" section</link> fur further information. </para> <para> <parameter>$options</parameter> - This parameter has the type <parameter>boolean</parameter>, if <parameter>$options</parameter> is true the connection will be persistent (requires support by database driver). Default is false. In future releases, this parameter will be an array and take different options depending on the database. </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - a newly created DB connection object, or a <classname>DB_Error</classname> object on error. </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.disconnect"> <refnamediv> <refname>DB::disconnect()</refname> <refpurpose>データベースからログアウトし、接続を切断する</refpurpose> </refnamediv> <refsect1 id="core.db.disconnect.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>disconnect</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$value</parameter> - the return object to check </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> if <parameter>$value</parameter> is an error, <parameter>false</parameter> if not marked up as error </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.iswarning"> <refnamediv> <refname>DB::isWarning()</refname> <refpurpose> DBメソッドからの結果コードが警告かどうか確認する </refpurpose> </refnamediv> <refsect1 id="core.db.iswarning.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>isWarning</function></funcdef> <paramdef>DB_Error <parameter>$value</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Warnings differ from errors in that they are generated by DB, and are not fatal. </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> if <parameter>$value</parameter> was an <classname>DB_Error</classname> object marked up as warning </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.iserror"> <refnamediv> <refname>DB::isError()</refname> <refpurpose> DBメソッドからの結果コードがエラーかどうか確認する </refpurpose> </refnamediv> <refsect1 id="core.db.iserror.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>isError</function></funcdef> <paramdef>DB_Error <parameter>$value</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>boolean</parameter> - <parameter>true</parameter> if <parameter>$value</parameter> was an <classname>DB_Error</classname> object </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.quote"> <refnamediv> <refname>DB::quote()</refname> <refpurpose> クエリで安全に使用可能なように文字列をクオートする </refpurpose> </refnamediv> <refsect1 id="core.db.quote.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>quote</function></funcdef> <paramdef>string <parameter>$string</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$string</parameter> - the input string to quote </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - NULL, if a NULL string was given, else the quoted string. </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.provides"> <refnamediv> <refname>DB::provides()</refname> <refpurpose> DB実装またはそのバックエンドの拡張モジュールが指定した機能をサポー トするかどうか調べる </refpurpose> </refnamediv> <refsect1 id="core.db.provides.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>provides</function></funcdef> <paramdef>string <parameter>$feature</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$feature</parameter> - name of the feature (see the DB class doc) </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>boolean</parameter> - whether the used DB implementation supports $feature </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.setfetchmode"> <refnamediv> <refname>DB::setFetchMode()</refname> <refpurpose> 指定した接続のクエリにおいてデフォルトに使用される取得モードを設 定する </refpurpose> </refnamediv> <refsect1 id="core.db.setfetchmode.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>setFetchMode</function></funcdef> <paramdef>integer <parameter>$fetchmode</parameter></paramdef> <paramdef>string <parameter><optional>$object_class</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$fetchmode</parameter> - <parameter>DB_FETCHMODE_ORDERED</parameter>, <parameter>DB_FETCHMODE_OBJECT</parameter> or <parameter>DB_FETCHMODE_ASSOC</parameter>, possibly bit-wise OR'ed with <parameter>DB_FETCHMODE_FLIPPED</parameter>. See <link linkend="core.db.tut_fetch">"Fetch"-section</link> for further information. </para> </listitem> <listitem> <para> <parameter>$object_class</parameter> - The class of the object to be returned by the fetch methods when the <parameter>DB_FETCHMODE_OBJECT</parameter> mode is selected. If no class is specified by default a cast to object from the assoc array row will be done. There is also the posibility to use and extend the 'DB_Row' class. </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - Nothing or a <parameter>PEAR_ERROR</parameter>, if <parameter>$fetchmode</parameter> contains a unknown value. </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.prepare"> <refnamediv> <refname>DB::prepare()</refname> <refpurpose> execute()で複数回実行するようクエリを準備する </refpurpose> </refnamediv> <refsect1 id="core.db.prepare.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>resource <function>prepare</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> </funcprototype> </funcsynopsis> <para> <function>Prepare</function> requires a generic query as string like "INSERT INTO numbers VALUES(?,?,?)". The ? are wildcards. Types of wildcards: <simplelist> <member> <parameter>?</parameter> - a quoted scalar value, i.e. strings, integers </member> <member> <parameter>&</parameter> - requires a file name, the content of the file insert into the query (i.e. saving binary data in a db). </member> <member> <parameter>!</parameter> - value is inserted 'as is' </member> </simplelist> See <link linkend="core.db.tut_execute">"Execute"-section</link> for further information. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the query to prepare </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>resource</parameter> - the query handle </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.execute"> <refnamediv> <refname>DB::execute()</refname> <refpurpose>準備したSQLクエリで実行する</refpurpose> </refnamediv> <refsect1 id="core.db.execute.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>execute</function></funcdef> <paramdef>string <parameter>$stmt</parameter></paramdef> <paramdef>array <parameter>$data</parameter></paramdef> </funcprototype> </funcsynopsis> <para> With <function>execute</function> the generic query of prepare is assigned with the given data array. The values of the array inserted into the query in the same order like the array order. See <link linkend="core.db.tut_execute">"Execute"-section</link> for further information. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$stmt</parameter> - query handle from <link linkend="core.db.prepare"><function>prepare</function> </link> </para> </listitem> <listitem> <para> <parameter>$data</parameter> - numeric array containing the data to insert into the query </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>resource</parameter> - a new <classname>DB_Result</classname> or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.executemultiple"> <refnamediv> <refname>DB::executeMultiple()</refname> <refpurpose>準備したSQLクエリを複数回実行する</refpurpose> </refnamediv> <refsect1 id="core.db.executemultiple.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>executeMultiple</function></funcdef> <paramdef>string <parameter>$stmt</parameter></paramdef> <paramdef>array <parameter>$data</parameter></paramdef> </funcprototype> </funcsynopsis> <para> This function does several <function>execute</function> calls on the same statement handle. $data must be an array indexed numerically from 0, one execute call is done for every "row" in the array. If an error occurs during <function>execute</function>, <function>executeMultiple</function> does not execute the unfinished rows, but rather returns that error. See <link linkend="core.db.tut_execute">"Execute"-section</link> for further information. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$stmt</parameter> - query handle from <link linkend="core.db.prepare"><function>prepare</function> </link> </para> </listitem> <listitem> <para> <parameter>$data</parameter> - numeric array containing the data to insert into the query </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>resource</parameter> - a new <classname>DB_Result</classname> or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.query"> <refnamediv> <refname>DB::query()</refname> <refpurpose>Send a query to the database</refpurpose> </refnamediv> <refsect1 id="core.db.query.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;query</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>array <parameter><optional>$params</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> See <link linkend="core.db.tut_query">"Execute"-section</link> for further information. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query or the statement to prepare </para> </listitem> <listitem> <para> <parameter>$params</parameter> - $params the data to be added to the query </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>resource</parameter> - a new <classname>DB_Result</classname> or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.limitquery"> <refnamediv> <refname>DB::limitQuery()</refname> <refpurpose>Generates a limited query <emphasis>EXPERIMENTAL!</emphasis></refpurpose> </refnamediv> <refsect1 id="core.db.limitquery.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;limitQuery</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>integer <parameter>$from</parameter></paramdef> <paramdef>integer <parameter>$count</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query or the statement to prepare </para> </listitem> <listitem> <para> <parameter>$from</parameter> - the row to start to fetching </para> </listitem> <listitem> <para> <parameter>$count</parameter> - the numbers of rows to fetch </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>resource</parameter> - a new <classname>DB_Result</classname> or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.getone"> <refnamediv> <refname>DB::getOne()</refname> <refpurpose>Fetch the first column of the first row from a query</refpurpose> </refnamediv> <refsect1 id="core.db.getone.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;getOne</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>array <parameter><optional>$params</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Fetch the first column of the first row of data returned from a query. Takes care of doing the query and freeing the results when finished. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query or the statement to prepare </para> </listitem> <listitem> <para> <parameter>$params</parameter> - if supplied, prepare/execute will be used with this array as execute parameters </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the returned value or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.getrow"> <refnamediv> <refname>DB::getRow()</refname> <refpurpose>Fetch the first row from a query</refpurpose> </refnamediv> <refsect1 id="core.db.getrow.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;getRow</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>array <parameter><optional>$params</optional></parameter></paramdef> <paramdef>integer <parameter><optional>$fetchmode</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Fetch the first row of data returned from a query. Takes care of doing the query and freeing the results when finished. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query </para> </listitem> <listitem> <para> <parameter>$params</parameter> - if supplied, prepare/execute will be used with this array as execute parameters </para> </listitem> <listitem> <para> <parameter>$fetchmode</parameter> - the fetch mode to use, default is <parameter>DB_FETCHMODE_DEFAULT</parameter> </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the first row of results as an array indexed from 0 or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.getcol"> <refnamediv> <refname>DB::getCol()</refname> <refpurpose>Fetch a single column from a query</refpurpose> </refnamediv> <refsect1 id="core.db.getcol.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;getCol</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>mixed <parameter><optional>$col</optional></parameter></paramdef> <paramdef>array <parameter><optional>$params</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Fetch a single column from a result set and return it as an indexed array. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query </para> </listitem> <listitem> <para> <parameter>$col</parameter> - which column to return (integer [column number, starting at 0] or string [column name]), default is <parameter>0</parameter> </para> </listitem> <listitem> <para> <parameter>$params</parameter> - if supplied, prepare/execute will be used with this array as execute parameters </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the first row of results as an array indexed from 0 or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.getassoc"> <refnamediv> <refname>DB::getAssoc()</refname> <refpurpose> Fetch the result set as an associative array using the first column as the key. </refpurpose> </refnamediv> <refsect1 id="core.db.getassoc.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>array <function>&amp;getAssoc</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef> boolean <parameter><optional>$force_array</optional></parameter></paramdef> <paramdef> array <parameter><optional>$params</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Fetch the entire result set of a query and return it as an associative array using the first column as the key. If the result set contains more than two columns, the value will be an array of the values from column 2-n. If the result set contains only two columns, the returned value will be a scalar with the value of the second column (unless forced to an array with the $force_array parameter). A DB error code is returned on errors. If the result set contains fewer than two columns, a <parameter>DB_ERROR_TRUNCATED</parameter> error is returned. </para> <para> A using example: <example> <title>"mytable"</title> <programlisting> <![CDATA[ ID TEXT DATE ---------------------- 1 'one' 944679408 2 'two' 944679408 3 'three' 944679408 ]]> </programlisting> </example> Then the call getAssoc('SELECT id,text FROM mytable') returns: <example> <title>returned array - version 1</title> <programlisting> <![CDATA[ array( '1' => 'one', '2' => 'two', '3' => 'three', ) ]]> </programlisting> </example> ...while the call getAssoc('SELECT id,text,date FROM mytable') returns: <example> <title>returned array - version 2</title> <programlisting> <![CDATA[ array( '1' => array('one', '944679408'), '2' => array('two', '944679408'), '3' => array('three', '944679408') ) ]]> </programlisting> </example> </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query </para> </listitem> <listitem> <para> <parameter>$force_array</parameter> - used only when the query returns exactly two columns. If true, the values of the returned array will be one-element arrays instead of scalars. </para> </listitem> <listitem> <para> <parameter>$params</parameter> - if supplied, prepare/execute will be used with this array as execute parameters </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>array</parameter> - associative array with results from the query. </para> </listitem> </itemizedlist> </para> <note> <para> Keep in mind that database functions in PHP usually return string values for results regardless of the database's internal type. </para> </note> </refsect1> </refentry> <refentry id="core.db.getall"> <refnamediv> <refname>DB::getAll()</refname> <refpurpose>Fetch all the rows returned from a query.</refpurpose> </refnamediv> <refsect1 id="core.db.getall.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>&amp;getAll</function></funcdef> <paramdef>string <parameter>$query</parameter></paramdef> <paramdef>array <parameter><optional>$params</optional></parameter></paramdef> <paramdef>integer <parameter><optional>$fetchmode</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$query</parameter> - the SQL query </para> </listitem> <listitem> <para> <parameter>$params</parameter> - if supplied, prepare/execute will be used with this array as execute parameters </para> </listitem> <listitem> <para> <parameter>$fetchmode</parameter> - the fetch mode to use, default: <parameter>DB_FETCHMODE_DEFAULT</parameter> </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - an nested array or a <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.affectedrows"> <refnamediv> <refname>DB::affectedRows()</refname> <refpurpose>returns the affected rows of a query</refpurpose> </refnamediv> <refsect1 id="core.db.affectedrows.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>affectedRows</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - number of rows or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.nextid"> <refnamediv> <refname>DB::nextId()</refname> <refpurpose>returns the next free id of a sequence</refpurpose> </refnamediv> <refsect1 id="core.db.nextid.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>nextId</function></funcdef> <paramdef>string <parameter>$seq_name</parameter></paramdef> <paramdef>boolean <parameter><option>$on_demand</option></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$seq_name</parameter> - name of the sequence </para> </listitem> <listitem> <para> <parameter>$ondemand</parameter> - when true the sequence is automatic created, if it not exists. Default ist <parameter> true</parameter> </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - a free id or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.createsequence"> <refnamediv> <refname>DB::createSequence()</refname> <refpurpose>creates a new sequence</refpurpose> </refnamediv> <refsect1 id="core.db.createsequence.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>createSequence</function></funcdef> <paramdef>string <parameter>$seq_name</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$seq_name</parameter> - name of the new sequence </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the result of creating query or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.dropsequence"> <refnamediv> <refname>DB::dropSequence()</refname> <refpurpose>deletes a sequence</refpurpose> </refnamediv> <refsect1 id="core.db.dropsequence.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>dropSequence</function></funcdef> <paramdef>string <parameter>$seq_name</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$seq_name</parameter> - name of the sequence </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the result of the dropping query or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.tableinfo"> <refnamediv> <refname>DB::tableInfo()</refname> <refpurpose>returns meta data about the result set</refpurpose> </refnamediv> <refsect1 id="core.db.tableinfo.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>tableInfo</function></funcdef> <paramdef>DB_Result <parameter>$result</parameter></paramdef> <paramdef>mode <parameter><optional>$mode</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$result</parameter> - the result object to analyse </para> </listitem> <listitem> <para> <parameter>$mode</parameter> - depends on database implementation <itemizedlist> <listitem> <para> FrontBase, MS-SQL, MySQL, PostgreSQL <itemizedlist> <listitem><para><parameter>false</parameter> (default) returns this array <programlisting> <![CDATA[ [0]["table"] table name [0]["name"] field name [0]["type"] field type [0]["len"] field length [0]["flags"] field flags ]]> </programlisting> </para> </listitem> <listitem><para><parameter>DB_TABLEINFO_ORDER</parameter> returns this array <programlisting> <![CDATA[ ["num_fields"] number of metadata records [0]["table"] table name [0]["name"] field name [0]["type"] field type [0]["len"] field length [0]["flags"] field flags ["order"][field name] index of field named "field name" ]]> </programlisting> The last one is used, if you have a field name, but no index. Test: if (isset($result['meta']['myfield'])) { ... </para> </listitem> <listitem><para><parameter>DB_TABLEINFO_ORDERTABLE</parameter> returns the same as above. But additionally <programlisting> <![CDATA[ ["ordertable"][table name][field name] index of field named "field name" ]]> </programlisting> This is, because if you have fields from different tables with the same field name * they override each other with <parameter>DB_TABLEINFO_ORDER</parameter>. </para> </listitem> </itemizedlist> </para> </listitem> <listitem> <para> InterBase, Informix, mSQL, Oracle8, ODBC, Sybase - No information </para> </listitem> </itemizedlist> </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the result of the dropping query or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.getlistof"> <refnamediv> <refname>DB::getListOf()</refname> <refpurpose>list internal DB info</refpurpose> </refnamediv> <refsect1 id="core.db.getlistof.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>getListOf</function></funcdef> <paramdef>string <parameter>$type</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$type</parameter> - type of requested info valid values for $type are db dependent, often: <parameter>"databases"</parameter>, <parameter>"users"</parameter>, <parameter>"view"</parameter>, <parameter>"functions"</parameter> </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - the requested data or <classname>DB_Error</classname> when fail </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.dbresult"> <refnamediv> <refname>DB_Result</refname> <refpurpose>contains the result of a database query</refpurpose> </refnamediv> <refsect1 id="core.db.tut_dbresult.desc"> <title>説明</title> <para> A reference to an instance of <classname>DB_Result</classname> is returned by database query functions like <link linkend="core.db.query"> <function>query</function></link> or <link linkend="core.db.query"> <function>execute</function></link>. The <classname>DB_Result</classname> provides different functions for accessing the result set of a SQL query. </para> </refsect1> </refentry> <refentry id="core.db.fetchrow"> <refnamediv> <refname>DB_Result::fetchRow()</refname> <refpurpose>Fetch and return a row of data</refpurpose> </refnamediv> <refsect1 id="core.db.fetchrow.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>fetchRow</function></funcdef> <paramdef>integer <parameter><optional>$fetchmode</optional></parameter> </paramdef> <paramdef>integer <parameter><optional>$rownum</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$fetchmode</parameter> - format of fetched row. Default is <parameter>DB_FETCHMODE_DEFAULT</parameter>. See the <link linkend="core.db.tut_fetch">"Fetch" section</link> for further information. </para> <para> <parameter>$rownum</parameter> - the row number to fetch. Default is <parameter>null</parameter>. </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - array a row of data, NULL on no more rows or DB_Error on error </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.fetchinto"> <refnamediv> <refname>DB_Result::fetchInto()</refname> <refpurpose>Fetch a row of data into an existing variable.</refpurpose> </refnamediv> <refsect1 id="core.db.fetchinto.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>fetchInto</function></funcdef> <paramdef>mixed <parameter>$arr</parameter> </paramdef> <paramdef>integer <parameter><optional>$fetchmode</optional></parameter> </paramdef> <paramdef>integer <parameter><optional>$rownum</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> See the <link linkend="core.db.tut_fetch">"Fetch" section</link> for further information. </para> <para> Parameter <itemizedlist> <listitem> <para> <parameter>$arr</parameter> - reference to data containing the row </para> <para> <parameter>$fetchmode</parameter> - format of fetched row. Default is <parameter>DB_FETCHMODE_DEFAULT</parameter>. </para> <para> <parameter>$rownum</parameter> - the row number to fetch. Default is <parameter>null</parameter>. </para> </listitem> </itemizedlist> </para> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - DB_OK on success, NULL on no more rows or DB_Error on error </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.numcols"> <refnamediv> <refname>DB_Result::numCols()</refname> <refpurpose>Get the the number of columns in a result set.</refpurpose> </refnamediv> <refsect1 id="core.db.numcols.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>integer <function>numCols</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>integer</parameter> - the number of columns or a DB_Error </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.numrows"> <refnamediv> <refname>DB_Result::numRows()</refname> <refpurpose>Get the the number of rows in a result set.</refpurpose> </refnamediv> <refsect1 id="core.db.numrows.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>integer <function>numRows</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>integer</parameter> - the number of rows or a DB_Error </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.nextresult"> <refnamediv> <refname>DB_Result::nextResult()</refname> <refpurpose>Get the next result if a batch of queries was executed.</refpurpose> </refnamediv> <refsect1 id="core.db.nextresult.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>boolean <function>nextResult</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>boolean</parameter> - true if a new result is available or false if not </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.free"> <refnamediv> <refname>DB_Result::free()</refname> <refpurpose>Frees the resources allocated for this result set.</refpurpose> </refnamediv> <refsect1 id="core.db.free.desc"> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>mixed <function>free</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> Returns <itemizedlist> <listitem> <para> <parameter>mixed</parameter> - true on success or a DB_Error on failure </para> </listitem> </itemizedlist> </para> </refsect1> </refentry> <refentry id="core.db.dberror"> <refnamediv> <refname>DB_Error</refname> <refpurpose>Class for reporting portable database error messages.</refpurpose> </refnamediv> <refsect1 id="core.db.dberror.desc"> <title>説明</title> <para> In case of failure, the most <classname>PEAR::DB</classname> functions return a <classname>DB_Error</classname>. The object contains information about the occured error. <classname>DB_Error</classname> offers the same functions like <classname>PEAR_Error</classname>. </para> </refsect1> </refentry> <refentry id="core.db.dbwarning"> <refnamediv> <refname>DB_Warning</refname> <refpurpose>Class for reporting portable database warning messages.</refpurpose> </refnamediv> <refsect1 id="core.db.dbwarning.desc"> <title>説明</title> <para> <classname>PEAR::DB</classname> functions can return a <classname>DB_Warning</classname>. The object contains information about the occured warning. <classname>DB_Warning</classname> offers the same functions like <classname>PEAR_Error</classname>. </para> </refsect1> </refentry> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/core/http.xml +++ peardoc/ja/core/http.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference id="http"> <title>HTTP関数</title> <titleabbrev>PEAR HTTP</titleabbrev> <partintro> <simpara> </simpara> </partintro> <refentry id="core.http.http"> <refnamediv> <refname>HTTP</refname> <refpurpose>HTTPユーティリティクラス</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis>require_once "HTTP.php";</synopsis> </refsynopsisdiv> <refsect1> <title>説明</title> <simpara> HTTPユーティリティ関数。 </simpara> </refsect1> <refsect1 id="core.http.http.date"> <title>HTTP::date</title> <funcsynopsis> <funcprototype> <funcdef>string <function>HTTP::date</function></funcdef> <paramdef>integer <parameter>time</parameter></paramdef> </funcprototype> </funcsynopsis> <para> RFC互換のHTTPヘッダをフォーマットします。この関数は、php.iniディ レクティブ"y2k_compliance"に依存します。 </para> <para> パラメータ<parameter>time</parameter>は、RFC互換の日付に変換され たUNIXタイムスタンプである必要があります。この値が、この関数によ り返されます。 </para> </refsect1> <refsect1 id="core.http.http.negotiateLanguage"> <title>HTTP::negotiateLanguage</title> <funcsynopsis> <funcprototype> <funcdef>string <function>HTTP::negotiateLanguage</function></funcdef> <paramdef>array <parameter>supported</parameter></paramdef> <paramdef>string <parameter>default</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Accept-Language HTTPヘッダまたはユーザのホストアドレスによりユー ザのブラウザと言語の交渉を行います。 言語コードは通常、1つの国のみで話されている言語の場合は、"ll"の 形式、特定の国で話されている言語の場合は、"ll_CC"となります。 例えば、アメリカ英語は"en_US"、イギリス英語は"en_UK"です。 ポルトガルで話されるポルトガル語は、"pt_PT"、ブラジルのポルトガル 語は、"pt_BR"です。2文字の国コードは、ISO 3166規格で参照可能です。 </para> <para> Quantities in the Accept-Language: header are supported, for example: </para> <para> <programlisting> Accept-Language: en_UK;q=0.7, en_US;q=0.6, no;q=1.0, dk;q=0.8 </programlisting> </para> <para> The first parameter <parameter>supported</parameter> is an associative array indexed by language codes (country codes) supported by the application. Values must evaluate to true. </para> <para> The second parameter <parameter>default</parameter> is the default language that should be used when if none of the other languages is found during negotiation. The default value for this parameter is "en_US" for U.S. English. </para> </refsect1> </refentry> <refentry id="core.http.compress"> <refnamediv> <refname>Compress</refname> <refpurpose>HTTP圧縮</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis> require_once "HTTP/Compress.php"; HTTP_Compress::start(); /** Your output goes here */ HTTP_Compress::output(); </synopsis> </refsynopsisdiv> <refsect1> <title>説明</title> <simpara></simpara> </refsect1> <refsect1 id="core.http.compress.start"> <title>HTTP_Compress::start</title> <funcsynopsis> <funcprototype> <funcdef>void <function>HTTP_Compress::start</function></funcdef> <paramdef></paramdef> </funcprototype> </funcsynopsis> <para> 出力バッファを開始し、データが常にバッファリングされるよう暗黙の フラッシュをオフにします。 </para> </refsect1> <refsect1 id="core.http.compress.output"> <title>HTTP_Compress::output</title> <funcsynopsis> <funcprototype> <funcdef>void <function>HTTP_Compress::output</function></funcdef> <paramdef>boolean <parameter><optional>compress</optional></parameter></paramdef> <paramdef>boolean <parameter><optional>use_etag</optional></parameter></paramdef> <paramdef>boolean <parameter><optional>send_body</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Output the contents of the output buffer, compressed if desired, along with any relevant headers. </para> <para> The first parameter <parameter>compress</parameter> defines if gzip compression should be used. (Note: The browser of the user has to support gzip also). The second parameter <parameter> use_etag</parameter> defines wether to generate an ETag, and don't send the body if the browser has the same object cached. <parameter>send_body</parameter> determines wether to send the body of the request? (Might be false for HEAD requests.) </para> </refsect1> </refentry> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/core/log.xml +++ peardoc/ja/core/log.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference id="core.log"> <title>ロギング関数</title> <titleabbrev>PEARログ</titleabbrev> <partintro> <simpara> </simpara> </partintro> <refentry id="core.log.container"> <refnamediv> <refname>ロギングコンテナ</refname> <refpurpose> <classname>Log</classname> は、複数のデータコンテナをサポートしま す。 </refpurpose> </refnamediv> <refsect1 id="core.log.container.file"> <title>'file' - Log_file</title> <para> データをローカルファイルシステムの任意のファイルに保存します。 (localとは、PHPのファイルシステム関数によりアクセス可能な全てのファ イルを意味します) </para> </refsect1> <refsect1 id="core.log.container.mcal"> <title>'mcal' - Log_mcal</title> <para> カレンダー関数にデータを保存します。この関数は、 <command>libmcal</command>と<command>mcal</command> PHP拡張モジュー ルを必要とします。 </para> </refsect1> <refsect1 id="core.log.container.sql"> <title>'sql' - Log_sql</title> <para> <link linkend="core.db">PEAR::DB</link>を用いて データベースにデータを保存します。 </para> </refsect1> <refsect1 id="core.log.container.syslog"> <title>'sql' - Log_syslog</title> <para> UNIXベースのシステムでは<command>syslog</command>、 Windows NT/2000/XPでは<command>イベントログ</command>を用いてデー タを保存します。 </para> </refsect1> </refentry> <refentry id="core.log.init"> <refnamediv> <refname>初期化</refname> <refpurpose><classname>Log</classname>オブジェクトを作成する</refpurpose> </refnamediv> <refsect1> <title></title> <para> There are three possible methods to create a <classname>Log</classname> object. You can create a <classname>Log_</classname> object directly or call either the <link linkend="core.log.log.singleton"><function> &amp;singleton</function></link> or the <link linkend="core.log.log.factory"><function>factory</function> </link> method of the <classname>Log</classname> class. </para> <example> <title>初期化の例</title> <programlisting role="php"> <![CDATA[ // direct initialization of the 'file' container $log = new Log_file('log.txt', 'identity text'); // initialization of the 'file' container through factory() $log = Log::factory('file', 'log.txt', 'identity text'); // initialization of the 'file' container through singelton() $log = &Log::singelton('file', 'log.txt', 'identity text'); ]]> </programlisting> </example> <para> Directly initializing an instance of the <classname>Log</classname> is probably the easiest method to understand. </para> <para> The second two approaches make use of software engineering design patterns (the "factory" and "singleton" metaphors). </para> <para> Specifically, calling the <function>factory</function> method will create a new instance of one of the <classname>Log_</classname> subclasses. The type of subclass that is returned is specified by the first parameter (<parameter>log_type</parameter>) passed to the <function>factory</function> method. This approach effectively hides the subclasses while still allowing the programmer to request a concrete instance of a certain subclass. This is useful in cases where the subclass type needs to be chosen at runtime. </para> <para> The <function>factory</function> method must always be called using PHP's static method notation - <literal>Log::factory</literal>. </para> <para> The <function>singleton</function> method is identical to the <function>factory</function> method except that it guarantees that only a single instance of the requested <classname>Log_</classname> subclass exists. The <function>singleton</function> method bases each instance's uniqueness on the parameters used in the instance's creation. In other words, only one instance with a given set of creation parameters will ever be returned by the <function>singleton</function> method. The second invocation will simply return a reference to the existing instance. </para> <para> The <function>singleton</function> method must also be called statically. In addition, it requires PHP's reference notation - <literal>&amp;Log::singleton</literal>. </para> </refsect1> </refentry> <refentry id="core.log.log"> <refnamediv> <refname>Log</refname> <refpurpose>ログ抽象化クラス</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis>require_once "Log.php";</synopsis> </refsynopsisdiv> <refsect1> <title>説明</title> <simpara> Logging interface functions. </simpara> </refsect1> <refsect1 id="core.log.log.factory"> <title>Log::factory</title> <funcsynopsis> <funcprototype> <funcdef>object <function>Log::factory</function></funcdef> <paramdef>string <parameter>log_type</parameter></paramdef> <paramdef>string <parameter><optional>log_name</optional></parameter></paramdef> <paramdef>string <parameter><optional>ident</optional></parameter></paramdef> <paramdef>array <parameter><optional>conf</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Return a concrete Log instance of <parameter>log_type</parameter>. </para> </refsect1> <refsect1 id="core.log.log.singleton"> <title>Log::singleton</title> <funcsynopsis> <funcprototype> <funcdef>object <function>Log::singleton</function></funcdef> <paramdef>string <parameter>log_type</parameter></paramdef> <paramdef>string <parameter><optional>log_name</optional></parameter></paramdef> <paramdef>string <parameter><optional>ident</optional></parameter></paramdef> <paramdef>array <parameter><optional>conf</optional></parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns a reference to a concrete Log instance of <parameter>log_type</parameter>, only creating a new instance if no Log instance with the same parameters currently exists. </para> <para> You should use this if there are multiple places you might create a logger, you don't want to create multiple loggers, and you don't want to check for the existance of one each time. The singleton pattern does all the checking work for you. </para> <para> <note> <simpara> You MUST call this method with the <literal>$var = &amp;Log::singleton() </literal>syntax. Without the ampersand (&amp;) in front of the method name, you will not get a reference; you will get a copy. </simpara> </note> </para> </refsect1> <refsect1 id="core.log.log.attach"> <title>Log::attach</title> <funcsynopsis> <funcprototype> <funcdef><function>Log::attach</function></funcdef> <paramdef>object <parameter>logObserver</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Adds a <link linkend="core.log.observer">Log_Observer</link> instance to the list of observers that are to be notified when a message is logged. </para> </refsect1> <refsect1 id="core.log.log.detach"> <title>Log::detach</title> <funcsynopsis> <funcprototype> <funcdef><function>Log::detach</function></funcdef> <paramdef>object <parameter>logObserver</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Removes a <link linkend="core.log.observer">Log_Observer</link> instance from the list of observers. </para> </refsect1> <refsect1 id="core.log.log.notifyall"> <title>Log::notifyAll</title> <funcsynopsis> <funcprototype> <funcdef><function>Log::notifyAll</function></funcdef> <paramdef>array <parameter>messageOb</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Sends any <link linkend="core.log.observer">Log_Observer</link> objects listening to this Log the message that was just logged. </para> </refsect1> </refentry> <refentry id="core.log.observer"> <refnamediv> <refname>Log_Observer</refname> <refpurpose>Log観測クラス</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis>require_once "Log/Log_Observer.php";</synopsis> </refsynopsisdiv> <refsect1> <title>説明</title> <simpara> Log_Observerクラスは、ログ処理を監視し、重要なイベントが発生した 場合に行動を起こすために、Subject-ObserverパターンのObserver側を 実装します。 </simpara> </refsect1> <refsect1 id="core.log.observer.factory"> <title>Log_Observer::factory</title> <funcsynopsis> <funcprototype> <funcdef>object <function>Log_Observer::factory</function></funcdef> <paramdef>string <parameter>observer_type</parameter></paramdef> <paramdef>integer <parameter><optional>priority</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <para> 指定した<parameter>observer_type</parameter>の具体的な Log_Observerインスタンスを返します。 </para> </refsect1> </refentry> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/core/mail.xml +++ peardoc/ja/core/mail.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference id="core.mail"> <title>PEAR Mail: メール処理関数</title> <titleabbrev>Mail</titleabbrev> <partintro> <simpara> 本章では、PEARに含まれるMail関数の使用法を説明します。 </simpara> </partintro> <refentry id="core.mail.Mail"> <refnamediv> <refname>Mail</refname> <refpurpose>Mail::クラスへのインターフェイスを提供する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> Mail::クラスへのインターフェイスを提供します。複数のメーラーバッ クエンドを使用する場合に有用なサポート関数です。 </simpara> </refsect1> <refsect1> <title><function>Mail::factory</function></title> <simpara> このメソッドは、Mail/ディレクトリにあるドライバクラスの1つから mailオブジェクトを作成するために使用されます。引数を二つとり、最 初の引数は使用するドライバの型、二番目はドライバオブジェクトのコ ンストラクタに渡すパラメータの配列となります。 </simpara> <programlisting role="php"> <![CDATA[ $params['host'] = 'localhost'; $params['port'] = 25; $mail_object =& Mail::factory('smtp', $params); ]]> </programlisting> <para> 正しい引数で $mail_objectの<function>send</function>メソッドをコー ルすることが可能となります。(Mail_mail, Mail_smtp, Mail_sendmail のドキュメントを参照) </para> </refsect1> </refentry> <refentry id="core.mail.phpmail"> <refnamediv> <refname>Mail/Mail.php</refname> <refpurpose> PHPの<function>mail</function>を用いてメールを送信する </refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> PHPの<function>mail</function>関数を用いる <function>send</function>メソッドを提供するドライバオブジェクト。 </simpara> </refsect1> <refsect1> <title><function>send</function></title> <simpara> このメソッドは、PHP組込みの<function>mail</function>関数を用いて メールを送信するメソッドです。他のドライバ関数と同様に3つの引数を とります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$recipients</parameter> - カンマ区切りの送信先の配 列 </para> </listitem> <listitem> <para> <parameter>$headers</parameter> - ヘッダの連想配列。ヘッダ名が キー、ヘッダの値は値となります。 </para> </listitem> <listitem> <para> <parameter>$body</parameter> - emailの本体。 </para> </listitem> </itemizedlist> </para> <programlisting role="php"> include('Mail.php'); $recipients = 'joe@example.com'; $headers['From'] = 'richard@phpguru.org'; $headers['To'] = 'joe@example.com'; $headers['Subject'] = 'Test message'; $body = 'Test message'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('mail'); $mail_object->send($recipients, $headers, $body); </programlisting> </refsect1> </refentry> <refentry id="core.mail.sendmail"> <refnamediv> <refname>Mail/sendmail.php</refname> <refpurpose>sendmailを使用してメールを送信する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> sendmailを使用する<function>send</function>メソッドを提供するドラ イバオブジェクト。 </simpara> </refsect1> <refsect1> <title>constructor</title> <simpara> $obj =& Mail::factory()構文を用いてオブジェクトを作成する際、メソッ ドに渡されるパラメータは、このオブジェクトのコンストラクタに順番 に渡されます。使用可能なパラメータを以下に示します。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$sendmail_path</parameter> - sendmail実行ファイルへ のパス。指定されない場合のデフォルトは、 <filename>/usr/sbin/sendmail</filename> </para> </listitem> <listitem> <para> <parameter>$sendmail_args</parameter> - sendmailに渡すオプショ ン引数の文字列。指定されない場合のデフォルトは、空白です。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>send</function></title> <simpara> このメソッドは、sendmailを用いてメールを送信します。他のドライバ 関数と同様に3つの引数をとります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$recipients</parameter> - カンマ区切りの送信先の配 列 </para> </listitem> <listitem> <para> <parameter>$headers</parameter> - ヘッダの連想配列。ヘッダ名が キー、ヘッダの値は値となります。 </para> </listitem> <listitem> <para> <parameter>$body</parameter> - emailの本体。 </para> </listitem> </itemizedlist> </para> <programlisting role="php"> <![CDATA[ include('Mail.php'); $recipients = 'joe@example.com'; $headers['From'] = 'richard@phpguru.org'; $headers['To'] = 'joe@example.com'; $headers['Subject'] = 'Test message'; $body = 'Test message'; $params['sendmail_path'] = '/usr/lib/sendmail'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('sendmail', $params); $mail_object->send($recipients, $headers, $body); ]]> </programlisting> </refsect1> </refentry> <refentry id="core.mail.smtp"> <refnamediv> <refname>Mail/smtp.php</refname> <refpurpose>SMTPを用いてメールを送信する</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> smtpを用いる<function>send</function>メソッドを提供するドライバオ ブジェクトです。サーバに接続するため、 filename>Net/smtp.php</filename>と <filename>Net/socket.php</filename>を使用します。 </simpara> </refsect1> <refsect1> <title>constructor</title> <simpara> $obj =& Mail::factory()構文を使用してオブジェクトを作成する際、 メソッドに渡されるパラメータは、このオブジェクトのコンストラクタ に順番に渡されます。使用可能なパラメータを以下に示します。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$host</parameter> - 接続するsmtpサーバ。 IPアドレスまたはホスト名。指定されない場合のデフォルトは、 localhostです。 </para> </listitem> <listitem> <para> <parameter>$port</parameter> - smtpサーバが実行されているポー ト。指定されない場合のデフォルトは、25です。 </para> </listitem> <listitem> <para> <parameter>$auth</parameter> - 認証を使用するかどうか。指定さ れない場合のデフォルトは、&false;です。 </para> </listitem> <listitem> <para> <parameter>$username</parameter> - 認証有りの接続で使用するユー ザ名。指定されない場合のデフォルトは、空白です。 </para> </listitem> <listitem> <para> <parameter>$password</parameter> - 認証有りの接続で使用するパ スワード。指定されない場合のデフォルトは、空白です。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>send</function></title> <simpara> このメソッドは、smtpを用いてメールを送信するメソッドです。 <filename>Net/Socket.php</filename>と <filename>Net/SMTP.php</filename>クラスを使用するため、これらが利 用可能である必要があります。他のドライバ関数と同様に3つの引数をと ります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$recipients</parameter> - カンマ区切りの送信先の配 列 </para> </listitem> <listitem> <para> <parameter>$headers</parameter> - ヘッダの連想配列。ヘッダ名が キー、ヘッダの値は値となります。 </para> </listitem> <listitem> <para> <parameter>$body</parameter> - emailの本体。 </para> </listitem> </itemizedlist> </para> <programlisting role="php"> <![CDATA[ include('Mail.php'); $recipients = 'joe@example.com'; $headers['From'] = 'richard@phpguru.org'; $headers['To'] = 'joe@example.com'; $headers['Subject'] = 'Test message'; $body = 'Test message'; $params['host'] = 'mail.example.com'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('smtp', $params); $mail_object->send($recipients, $headers, $body); ]]> </programlisting> </refsect1> </refentry> <refentry id="core.mail.mime"> <refnamediv> <refname>Mail/mime.php</refname> <refpurpose>マルチパートメッセージを作成するクラス</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> 複雑なマルチパートメッセージを簡単に作成するためのクラスです。 このようなemailを作成するための簡単なAPIを探している場合は、この クラスが恐らく適当でしょう。一方、emailを高度に制御したい場合には、 <filename>mimePart.php</filename>を使用する方が良いかもしれません。 </simpara> </refsect1> <refsect1> <title>constructor</title> <simpara> コンストラクタは、引数を1つだけとります。この引数は、使用する行末 の型です。標準は、CRLFですが、*nixではLFが広く使われ、MacはCRです。 </simpara> </refsect1> <refsect1> <title><function>setTXTBody</function></title> <simpara> この関数は、emailのテキスト部分を設定します。以下に示す引数を2つ とります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$data</parameter> - 設定するテキストまたは使用する テキストファイルのファイル名。 </para> </listitem> <listitem> <para> <parameter>$isfile</parameter> - オプション。&true;の場合、 <parameter>$data</parameter>はファイル名と仮定され、読み込まれ ます。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>setHTMLBody</function></title> <simpara> この関数は、emailのHTMLの部分を設定します。次の2つの引数をとりま す。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$data</parameter> - 設定するHTMLまたは、使用するテ キストファイルのファイル名。 </para> </listitem> <listitem> <para> <parameter>$isfile</parameter> - オプション。&true;の場合、 <parameter>$data</parameter>はファイル名と仮定され、読み込まれ ます。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>addHTMLImage</function></title> <simpara> 埋込みイメージとしてHTML emailを送信する場合、この関数をイメージ を追加するために使用して下さい。この関数は以下の4つの引数をとりま す。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$file</parameter> - ファイル名または実際のファイル データ自体。 </para> </listitem> <listitem> <para> <parameter>$c_type</parameter> - イメージ/ファイルのcontent type。指定されない場合のデフォルトは、application/octet-stream。 </para> </listitem> <listitem> <para> <parameter>$name</parameter> - イメージ/ファイルのファイル名。 指定されない場合のデフォルトは、空白です。 </para> </listitem> <listitem> <para> <parameter>$isfilename</parameter> - <parameter>$file</parameter>引数をファイル名とするかどうか。 &true;の場合、そのファイルが読み込まれます。指定されない場合の デフォルトは、&true;です。 </para> </listitem> </itemizedlist> </para> <para> <emphasis>注意:</emphasis> この関数は、埋め込みイメージを使用可能とするだけです。他のファイ ル型、例えばflashムービー、も埋め込み可能です。 </para> </refsect1> <refsect1> <title><function>addAttachment</function></title> <simpara> emailに添付ファイルを追加する。この関数は引数を以下の5個とります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$file</parameter> - ファイル名またはファイルデータ 自体。 </para> </listitem> <listitem> <para> <parameter>$c_type</parameter> - ファイルのContent type。 指定されない場合のデフォルトは、application/octet-stream。 </para> </listitem> <listitem> <para> <parameter>$name</parameter> - ファイルのファイル名。 指定されない場合のデフォルトは、空白。 </para> </listitem> <listitem> <para> <parameter>$isfilename</parameter> - <parameter>$file</parameter>引数をファイル名とするかどうか。 &true;の場合、そのファイルが読み込まれます。指定されない場合の デフォルトは、&true;です。 </para> </listitem> <listitem> <para> <parameter>$encoding</parameter> - ファイルデータに関して使用 するtransfer encodingの型。指定されない場合のデフォルトは、 base64です。(例えばscripts/htmlといった)テキストベースのファイ ルの場合、quoted-printableを指定することが可能です。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>get</function></title> <simpara> この関数は、text/html/images/attachmentsを追加する度に1度コール されます。この関数は、emailを作成し、返します。 送信は行いません。(headers()関数と組み合わせて)この関数が返すもの を送信するには、このドキュメントで説明されている <link linkend="core.mail.phpmail">Mail_mail</link>, <link linkend="core.mail.sendmail">Mail_sendmail</link>, <link linkend="core.mail.smtp">Mail_smtp</link>クラスの1つの使用 する必要があります。この関数は引数を1つだけとり、これは、パラメー タの連想配列です。これらのパラメータは、emailの作成方法を変更する もので、以下の要素からなります。 </simpara> <para> <itemizedlist> <listitem> <para> <parameter>$text_encoding</parameter> - emailのプレーンテキス トパートで使用するエンコーディングの型。デフォルトは、7bit。 </para> </listitem> <listitem> <para> <parameter>$html_encoding</parameter> - emailのHTMLパートで使 用するエンコーディングの型。デフォルトは、quoted-printable。 </para> </listitem> <listitem> <para> <parameter>$7bit_wrap</parameter> - テキストを折り返す文字数。 SMTPは、1行の最大長をCRLFを含んで1000文字と規定しています。デ フォルトは、998文字(CRLFを含んで1000文字)です。 </para> </listitem> <listitem> <para> <parameter>$text_charset</parameter> - emailのプレーンテキスト パートで使用される文字接と。デフォルトは、iso-8859-1。 </para> </listitem> <listitem> <para> <parameter>$html_charset</parameter> - emailのHTMLパートで使用 される文字セット。デフォルトは、iso-8859-1です。 </para> </listitem> </itemizedlist> </para> </refsect1> <refsect1> <title><function>headers</function></title> <simpara> この関数は、emailで必要な適切なヘッダを連想配列として返します。 この連想配列は、Mail_mail, Mail_sendmail, Mail_smtpクラスに直接渡 すことが可能です。この関数は、<function>get</function>をコールし た後にコールする必要があります。これは、<function>get</function> がいくつかの必要なヘッダを生成するためです。この関数は、引数を1 つだけとり、それは、返されるヘッダの連想配列にも含まれます。 この配列のキーはヘッダ名(例 From, Subject, X-Mailer)とし、値は、 そのヘッダの値とする必要があります。 </simpara> </refsect1> <refsect1> <title>例:</title> <simpara> 以下の例は、貼付ファイルを有する非常に簡単なhtml/text emailを作成 し、mailドライバのMail::send()関数(すなわち、Mail_mail::send())を 用いて送信するものです。 </simpara> <programlisting role="php"> <![CDATA[ include('Mail.php'); include('Mail/mime.php'); $text = 'Text version of email'; $html = '<html><body>HTML version of email</body></html>'; $file = '/home/richard/example.php'; $crlf = "\r\n"; $hdrs = array( 'From' => 'richard@phpguru.org', 'Subject' => 'Test mime message' ); $mime = new Mail_mime($crlf); $mime->setTXTBody($text); $mime->setHTMLBody($html); $mime->addAttachment($file, 'text/plain'); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send('joe@example.com', $hdrs, $body); ]]> </programlisting> </refsect1> </refentry> <refentry id="core.mail.mimeDecode"> <refnamediv> <refname>Mail/mimeDecode.php</refname> <refpurpose>MIMEメッセージで動作するクラス</refpurpose> </refnamediv> <refsect1> <title>説明</title> <simpara> このクラスは、 mime emails/message作成を支援するツールです。 この関数は指定した入力を有用なPHPデータ構造にデコードします。 データ構造は、以下の要素を有するオブジェクトです。 </simpara> <para> <emphasis>headers:</emphasis> An associative array of the headers. The keys of the array are the header names (lowercased) whilst the values are the header values (original case). if there are multiple headers with the same name (eg. Recieved: ) then the value is a numerically indexed array of each of the header values. If the parameter decode_headers is specified as true, then the headers will be decoded (RFC2047). </para> <para> <emphasis>ctype_primary:</emphasis> The first part of the content type (ie. before the forward slash). Eg. If the content type is multipart/mixed, ctype_primary would be "multipart" (no quotes). </para> <para> <emphasis>ctype_secondary:</emphasis> The second part of the content type. Eg. If the content type is multipart/mixed, ctype_secondary would be "mixed" (no quotes). </para> <para> <emphasis>ctype_parameters:</emphasis> if the content type header has any parameters (eg. boundary="=_hudfhdsalfhds8fy8329hfj") then they will be in this associative array. Keys are the parameter name (eg. boundary) whilst the values are the parameter values (eg. =_hudfhdsalfhds8fy8329hfj ). </para> <para> <emphasis>disposition:</emphasis> if the Content-Disposition header is present, it's value will be given here. This is usually either "inline" or "attachment" (no quotes). </para> <para> <emphasis>d_parameters:</emphasis> if any parameters are given with the Content-Disposition header, they will be given here in an associative array, keys being the parameter names and values being the parameter values. "name" and "filename" are two common examples here. </para> <para> <emphasis>body:</emphasis> if the include_bodies parameter is given when instanciating the class, (either statically or normally), then this will be present if the part in question has a body. Mime parts with content type multipart/* generally do not not have bodies, instead consisting of subparts. If the parameter decode_bodies is specified as true then the body will be decoded. </para> <para> <emphasis>parts:</emphasis> if a mime part consists of subparts, then this array will be present consisting of objects with the same properties as described here. </para> </refsect1> <refsect1> <title><function>Mail_mimeDecode::constructor</function></title> <simpara> オブジェクトとしてインスタンス作成が行われた場合、コンストラクタ は引数を以下の二つとります。 </simpara> <itemizedlist> <listitem> <para> <parameter>$input</parameter> - デコードするemail/message。 </para> </listitem> <listitem> <para> <parameter>$crlf</parameter> - オプション。This specifies the correct line ending to use. Usually either CRLF or just LF. This option can make the difference between this class working and not. You're strongly recommended to ensure you're email uses exclusively what this argument is set to. Default is CRLF. </para> </listitem> </itemizedlist> </refsect1> <refsect1> <title><function>Mail_mimeDecode::decode</function></title> <simpara> This function performs the decoding and returns the structure as detailed above. It takes just one argument which is an associative array of parameters. These parameters can consist of: </simpara> <itemizedlist> <listitem> <para> <parameter>$include_bodies</parameter> - Whether to include the bodies in the returned structure. </para> </listitem> <listitem> <para> <parameter>$decode_bodies</parameter> - Whether to decode the returned bodies. </para> </listitem> <listitem> <para> <parameter>$decode_headers</parameter> - Whether to decode the headers (RFC2047). </para> </listitem> <listitem> <para> <parameter>$input</parameter> - If and only if called statically, this should be used to specify the input to be decoded. </para> </listitem> <listitem> <para> <parameter>$crlf</parameter> - If and only if called statically, this should be used to specify the line ending type. </para> </listitem> </itemizedlist> </refsect1> <refsect1> <title><function>Mail_mimeDecode::uudecode</function></title> <simpara> This method is not called from the main decoding part of the class, but is included as it is a suitable location for it. Given some input it will check for any uuencoded attachments and return them in an associative array containing the file data, file perms and file name. It takes only one argument, that being the input to look at. This function can be called statically, even if you do not use the rest of the classes functionality. </simpara> </refsect1> <refsect1> <title><function>Mail_mimeDecode::getXML</function></title> <simpara> This method is not called from the main decoding part of the class. It takes the output returned by <function>decode</function> and converts it to XML using the DTD available here: http://www.phpguru.org/xmail/ or with the PEAR mime package (when it is available). The method takes only one argument, and that is the returned data from the <function>decode </function> method. </simpara> </refsect1> <refsect1> <title>Usage examples:</title> <simpara> This example instanciates the object normally and runs the decode function: </simpara> <programlisting role="php"> <![CDATA[ $params['include_bodies'] = TRUE; $params['decode_bodies'] = TRUE; $params['decode_headers'] = TRUE; $decoder = new Mail_mimeDecode($input); $structure = $decoder->decode($params); ]]> </programlisting> <para> This example calls the decode function statically (ie no object, straight function call) and then passes the structure to the <function>getXML</function> function. <programlisting role="php"> <![CDATA[ $params['include_bodies'] = TRUE; $params['decode_bodies'] = FALSE; $params['decode_headers'] = TRUE; $params['input'] = $input; $params['crlf'] = "\r\n"; $structure = Mail_mimeDecode::decode($params); $xml = Mail_mimeDecode::getXML($structure); ]]> </programlisting> </para> </refsect1> </refentry> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: peardoc/ja/core/pear.xml +++ peardoc/ja/core/pear.xml <?xml encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference id="reference"> <title>PEAR基底/エラー処理クラス</title> <titleabbrev>PEAR</titleabbrev> <partintro> <simpara> 本章には、PEAR基底クラス及びエラー処理用の機構が含まれます。本章は、 既にPHPのオブジェクトとクラスに関する知識を有していることを想定し ます。 </simpara> </partintro> <refentry id="class.pear"> <refnamediv> <refname>PEAR</refname> <refpurpose>PEAR基底クラス (デストラクタ, エラー処理)</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis>require_once "PEAR.php";</synopsis> <synopsis> class <replaceable>classname</replaceable> extends <classname>PEAR</classname> { ... } </synopsis> </refsynopsisdiv> <refsect1> <title>説明</title> <simpara> PEAR基底クラスは、多くのPEARクラスで使用される標準的な機能を提供 します。通常、PEARクラスのインスタンスを直接作成することはなく、 サブクラス化して使用します。 </simpara> <para> 主な機能は次のようになります。 <itemizedlist> <listitem> <simpara>リクエストシャットダウンオブジェクト "デストラクタ"</simpara> </listitem> <listitem> <simpara>エラー処理</simpara> </listitem> </itemizedlist> </para> </refsect1> <refsect1 id="destructors"> <title>PEAR "デストラクタ"</title> <simpara> <replaceable>ClassName</replaceable>という名前のクラスに <classname>PEAR</classname>を継承した場合、 _<replaceable>ClassName</replaceable>(クラス名の前にアンダースコ アを付けたもの)と呼ばれるメソッドを定義することが可能です。 これは、リクエスト終了時にコールされます。 これはオブジェクトを削除でき、デストラクタがコールされたと意味で のデストラクタではありませんが、PHPが実行を終了した時点でオブジェ クトのコールバック関数を指定するという意味でデストラクタです。 以下の<link linkend="example.destructors">例</link>を参照下さい。 </simpara> <para> <warning id="destructors.warning"> <title>重要!</title> <para> デストラクタが正しく動作するために、以下のように"=&amp; new"演 算子でクラスのインスタンスを作成する必要があります。 <programlisting role="php"> <![CDATA[ $obj =& new MyClass(); ]]> </programlisting> </para> <simpara> "= new"を使用した場合、PEAEに登録されたオブジェクトのシャットダ ウンリストは、コンストラクタがコールされた時点でそのオブジェク トのコピーとなります。これがリクエストシャットダウン時点でコー ルされるこのコピーの"デストラクタ"となります。 </simpara> </warning> </para> </refsect1> <refsect1 id="error-handling"> <title>PEARエラー処理</title> <simpara> PEARの基底クラスは、true/false値または数値コードよりも複雑なエラー を渡す手段を提供します。PEARエラーは、クラス <classname>PEAR_Error</classname>のインスタンスまたは <classname>PEAR_Error</classname>を継承したクラスのどちらかです。 </simpara> <simpara> PEARのエラーの設計指針の1つは、ユーザに特定の型の出力を強制するべ きではなく、望ましい場合に出力を全く行わないエラー処理を可能とす るべきです。これは、出力形式がHTMLではない(例えばWMLまたは他のXML 形式)場合に、エラー処理を高度に行うことを可能にします。 </simpara> <simpara> エラーオブジェクトは、エラーメッセージを出力する、メッセージを出 力して終了する、PHPの<function>trigger_error</function>関数でエラー を発生する、コールバックを起動する、または、これらを何もしない、 といった多くのことを作成時に設定することが可能です。これは、通常、 <classname>PEAR_Error</classname>のコンストラクタで指定されますが、 全てのパラメータはオプションで、<classname>PEAR</classname>クラス に基づく各オブジェクトから生成されたエラーのデフォルトを設定する ことが可能です。使用法については<link linkend="example.error1">PEARエラーの例</link>、詳細については、 <classname>PEAR_Error</classname>リファレンスを参照下さい。 </simpara> </refsect1> <refsect1> <title>例</title> <para> 以下の例は、ファイルの中身を保持する簡単なクラスを実装する際の PEARの"poor man's kinda emulated destructors"の使用法を示すもので す。このオブジェクトにデータを追加し、リクエスト終了時にファイル にデータを戻します。 <example id="example.destructors"> <title>PEAR: エミュレーションされたデストラクタ</title> <programlisting role="php"> <![CDATA[ require_once "PEAR.php"; class FileContainer extends PEAR { var $file = ''; var $contents = ''; var $modified = 0; function FileContainer($file) { $this->PEAR(); // this calls the parent class constructor $fp = fopen($file, "r"); if (!is_resource($fp)) { return; } while (!empty($data = fread($fp, 2048))) { $this->contents .= $data; } fclose($fp); } function append($str) { $this->contents .= $str; $this->modified++; } // The "destructor" is named like the constructor // but with an underscore in front. function _FileContainer() { if ($this->modified) { $fp = fopen($this->file, "w"); if (!is_resource($fp)) { return; } fwrite($fp, $this->contents); fclose($fp); } } } $fileobj =& new FileContainer("testfile"); $fileobj->append("this ends up at the end of the file\n"); // When the request is done and PHP shuts down, $fileobj's // "destructor" is called and updates the file on disk. ]]> </programlisting> </example> <note> <simpara> PEAR "デストタクタ"は、PHPのシャットダウン用コールバック (<function>register_shutdown_function</function>)を使用します。 そして、PHP &lt; 4.1では、PHPがWebサーバで実行されている場合に これらのコールバックから何も出力できません。PHPがコマンドライン のモードで使用される場合を除き、"デストラクタ"からの出力は全て 失われます。PHP 4.1以降では、デストラクタでも出力を行うことが可 能です。 </simpara> <simpara> また、デストラクタを使用したい場合は、オブジェクトのインスタン ス作成に関する<link linkend="destructors.warning">警告</link>を 参照下さい。 </simpara> </note> </para> <simpara> 次の例は、PEARのエラー処理機構の別の使用方法を説明するものです。 </simpara> <para> <example id="example.error1"> <title>PEARエラーの例(1)</title> <programlisting role="php"> <![CDATA[ function mysockopen($host = "localhost", $port = 8090) { $fp = fsockopen($host, $port, $errno, $errstr); if (!is_resource($fp)) { return new PEAR_Error($errstr, $errno); } return $fp; } $sock = mysockopen(); if (PEAR::isError($sock)) { print "mysockopen error: ".$sock->getMessage()."<BR>\n" } ]]> </programlisting> </example> </para> <simpara> この例は、PEARエラーオブジェクトの中でfsockopenで返されたエラーコー ド及びメッセージを受け渡す<function>fsockopen</function>のラッパー を示しています。<function>PEAR::isError</function>は、PEARエラー の値を検出するために使用されることに注意して下さい。 </simpara> <simpara> この例でPEAR_Errorの実行モードは、エラーオブジェクトを返し、ユー ザ(プログラマ)に処理を渡すだけです。これは、デフォルトのエラーモー ドです。 </simpara> <simpara> 次の例では、デフォルトのエラーモードを使用する方法を示しています。 </simpara> <para> <example id="example.error2"> <title>PEARエラーの例(2)</title> <programlisting role="php"> <![CDATA[ class TCP_Socket extends PEAR { var $sock; function TCP_Socket() { $this->PEAR(); } function connect($host, $port) { $sock = fsockopen($host, $port, $errno, $errstr); if (!is_resource($sock)) { return $this->raiseError($errstr, $errno); } } } $sock = new TCP_Socket; $sock->setErrorHandling(PEAR_ERROR_DIE); $sock->connect("localhost", 8090); print "still alive<BR>\n"; ]]> </programlisting> </example> </para> <simpara> この例では、デフォルトのエラーモードを <constant>PEAR_ERROR_DIE</constant>に設定しています。(3番目のパ ラメータとして)エラーモードをraiseErrorコールに設定しないため、 raiseErrorはデフォルトのエラーモードを使用し、fsockopenが失敗した 場合に終了します。 </simpara> </refsect1> <refsect1> <title>グローバル変数の使用</title> <para> PEARクラスは、グローバルデフォルトと"デストラクタ"で使用されるオ ブジェクトのリストを登録するためにいくつかのグローバル変数を使用 します。PEARクラスに関連する全てのグローバル変数は、接頭辞 <literal>_PEAR_</literal>を有します。 </para> <para> <variablelist> <varlistentry> <term>$_PEAR_default_error_mode</term> <listitem> <simpara> オブジェクトの中でデフォルトのエラーモードが設定されない場合、 このモードが使用されます。 <constant>PEAR_ERROR_RETURN</constant>, <constant>PEAR_ERROR_PRINT</constant>, <constant>PEAR_ERROR_TRIGGER</constant>, <constant>PEAR_ERROR_DIE</constant>, <constant>PEAR_ERROR_CALLBACK</constant>のどれかとする必要が あります。 </simpara> <para> この変数を直接設定せず、以下のように静的なメソッドとして <function>PEAR::setErrorHandling</function>をコールして下さい。 <informalexample> <programlisting role="php"> <![CDATA[ PEAR::setErrorHandling(PEAR_ERROR_DIE); ]]> </programlisting> </informalexample> </para> </listitem> </varlistentry> <varlistentry> <term>$_PEAR_default_error_options</term> <listitem> <simpara> エラーモードが、<constant>PEAR_ERROR_TRIGGER</constant>の場合、 これはエラーレベル( <constant>E_USER_NOTICE</constant>, <constant>E_USER_WARNING</constant>, <constant>E_USER_ERROR</constant>のどれか)です。 </simpara> <para> この変数を直接設定せず、以下のように静的メソッドとして <function>PEAR::setErrorHandling</function>をコールして下さい。 <informalexample> <programlisting role="php"> <![CDATA[ PEAR::setErrorHandling(PEAR_ERROR_TRIGGER, E_USER_ERROR); ]]> </programlisting> </informalexample> </para> </listitem> </varlistentry> <varlistentry> <term>$_PEAR_default_error_callback</term> <listitem> <simpara> エラーが発生し、エラーモードが <constant>PEAR_ERROR_CALLBACK</constant>の場合に、 <replaceable>options</replaceable>パラメータが指定されない時、 この変数の値がコールバックとして使用されます。これは、エラー モードを一時的に変更し、コールバック関数を再度設定せずにコー ルバックモードに戻ることが可能であることを意味します。 文字列の値は、関数を表し、添字0にオブジェクト、添字1にメソッ ドを有する要素数2の配列です。 </simpara> <para> この変数を直接を設定せずに、以下のように静的変数として <function>PEAR::setErrorHandling</function>をコールして下さい。 <informalexample> <programlisting role="php"> <![CDATA[ PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "my_error_handler"); ]]> </programlisting> </informalexample> </para> <para> 以下にコールバック関数を再度指定せずに切替える方法の例を示し ます。 <informalexample> <programlisting role="php"> <![CDATA[ PEAR::setErrorMode(PEAR_ERROR_CALLBACK, "my_function_handler"); do_some_stuff(); PEAR::setErrorMode(PEAR_ERROR_DIE); do_some_critical_stuff(); PEAR::setErrorMode(PEAR_ERROR_CALLBACK); // now we're back to using my_function_handler again ]]> </programlisting> </informalexample> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1> <title>メソッド</title> <refsect2 id="function.pear"> <title>PEAR::PEAR</title> <funcsynopsis> <funcprototype> <funcdef>PEAR()</funcdef> <void/> </funcprototype> </funcsynopsis> <para> これは、PEARクラスのコンストラクタです。PEARクラスを継承する全て のクラスのコンストラクタからコールします。 <example> <title>PEARクラスコンストラクタの例</title> <programlisting role="php"> <![CDATA[ class MyClass extends PEAR { var $foo, $bar; function MyClass($foo, $bar) { $this->PEAR(); $this->foo = $foo; $this->bar = $bar; } } ]]> </programlisting> </example> </para> </refsect2> <refsect2 id="function.-pear"> <title>PEAR::_PEAR</title> <funcsynopsis> <funcprototype> <funcdef>_PEAR()</funcdef> <void/> </funcprototype> </funcsynopsis> <para> これは、PEARクラスのデストラクタです。リクエストのシャットダウン の際にコールされます。 </para> </refsect2> </refsect1> </refentry> <refentry id="class.pear-error"> <refnamediv> <refname>PEAR_Error</refname> <refpurpose>PEARエラー機構の基底クラス</refpurpose> </refnamediv> <refsynopsisdiv> <synopsis>$err = new <classname>PEAR_Error</classname>($msg);</synopsis> </refsynopsisdiv> <refsect1> <title>エラーモード</title> <para> エラーオブジェクトは、次の定数のどれかを設定することが可能な処理 モードを有しています。 <variablelist id="error-modes"> <varlistentry id="constant.pear-error-return"> <term>PEAR_ERROR_RETURN</term> <listitem> <simpara> オブジェクトを返すだけで、PEAR_Errorのコンストラクタの中では 何もしません。 </simpara> </listitem> </varlistentry> <varlistentry id="constant.pear-error-print"> <term>PEAR_ERROR_PRINT</term> <listitem> <simpara> コンストラクタの中でエラーメッセージを出力します。実行は中断 されません。 </simpara> </listitem> </varlistentry> <varlistentry id="constant.pear-error-trigger"> <term>PEAR_ERROR_TRIGGER</term> <listitem> <simpara> PHPの内部エラーを発生するためにPHPの <function>trigger_error</function>関数を使用します。ユーザが 定義したPHPのエラーハンドラを定義している場合またはエラーのレ ベルをE_USER_ERRORに設定している場合は、実行は終了されます。 </simpara> </listitem> </varlistentry> <varlistentry id="constant.pear-error-die"> <term>PEAR_ERROR_DIE</term> <listitem> <simpara> エラーメッセージを出力し、終了します。実行はもちろん終了しま す。 </simpara> </listitem> </varlistentry> <varlistentry id="constant.pear-error-callback"> <term>PEAR_ERROR_CALLBACK</term> <listitem> <simpara> エラーを処理するためにコールバック関数またはメソッドを使用し ます。実行は終了されます。 </simpara> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1> <title>プロパティ</title> <simpara></simpara> </refsect1> <refsect1> <title>メソッド</title> <funcsynopsis> <funcprototype> <funcdef><function>PEAR_Error::PEAR_Error</function></funcdef> <paramdef> <parameter><optional>message</optional></parameter> <parameter><optional>code</optional></parameter> <parameter><optional>mode</optional></parameter> <parameter><optional>options</optional></parameter> <parameter><optional>userinfo</optional></parameter> </paramdef> </funcprototype> </funcsynopsis> <refsect2> <title>説明</title> <para> PEAR_Errorコンストラクタ。 パラメータ: <variablelist> <varlistentry> <term>message</term> <listitem> <simpara> エラーメッセージ、デフォルトは、"unknown error" </simpara> </listitem> </varlistentry> <varlistentry> <term>code</term> <listitem> <simpara> エラーコード (オプション) </simpara> </listitem> </varlistentry> <varlistentry> <term>mode</term> <listitem> <simpara> 実行モード。詳細は、<link linkend="error-modes">エラーモード </link>のセクションを参照下さい。 </simpara> </listitem> </varlistentry> <varlistentry> <term>options</term> <listitem> <simpara> オプションを指定可能なモードが指定された場合、このパラメータ を使用して下さい。現在、"trigger"および"callback"モードのみ が、このオプションのパラメータを使用しています。triggerモー ドの場合、このパラメータは、 <constant>E_USER_NOTICE</constant>, <constant>E_USER_WARNING</constant>, <constant>E_USER_ERROR</constant>のどれかを使用して下さい。 コールバックモードの場合、このパラメータは、 コールバック関数名(string)または2つの要素(object, string)を 含むオブジェクトおよびメソッド名を表す配列のどちらかを含む必 要があります。 </simpara> </listitem> </varlistentry> </variablelist> </para> </refsect2> </refsect1> </refentry> </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 sgml-parent-document:nil sgml-default-dtd-file:"../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.cvs (#2269) next »