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: | Rui Hirokawa | 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 © 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) && (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(&$dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$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><?php ?></literal> to delimit PHP code, not the <literal><? ?></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 $Id$ 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><pear base dir>/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>&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>&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>&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>&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>&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>&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>&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ãããã¾ãã¯ã¦ã¼ã¶ã®ãã¹ãã¢ãã¬ã¹ã«ããã¦ã¼ ã¶ã®ãã©ã¦ã¶ã¨è¨èªã®äº¤æ¸ãè¡ãã¾ãã è¨èªã³ã¼ãã¯é常ãï¼ã¤ã®å½ã®ã¿ã§è©±ããã¦ããè¨èªã®å ´åã¯ã"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> &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>&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 = &Log::singleton() </literal>syntax. Without the ampersand (&) 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ã追å ãã度ã«ï¼åº¦ã³ã¼ã« ããã¾ãããã®é¢æ°ã¯ã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>ã¯ã©ã¹ã®ï¼ã¤ã®ä½¿ç¨ ããå¿ è¦ãããã¾ãããã®é¢æ°ã¯å¼æ°ãï¼ã¤ã ãã¨ããããã¯ããã©ã¡ã¼ ã¿ã®é£æ³é åã§ãããããã®ãã©ã¡ã¼ã¿ã¯ã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> ãããã¤ãã®å¿ è¦ãªããããçæããããã§ãããã®é¢æ°ã¯ã弿°ãï¼ ã¤ã ãã¨ããããã¯ãè¿ããããããã®é£æ³é åã«ãå«ã¾ãã¾ãã ãã®é åã®ãã¼ã¯ãããå(ä¾ 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> ãã¹ãã©ã¯ã¿ãæ£ããåä½ããããã«ã以ä¸ã®ããã«"=& 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 < 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>ã«è¨å®ãã¦ãã¾ãã(ï¼çªç®ã®ã ã©ã¡ã¼ã¿ã¨ãã¦)ã¨ã©ã¼ã¢ã¼ãã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 -->
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 © 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) && (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(&$dsn, $persistent = false) { if (is_array($dsn)) { $dsninfo = &$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><?php ?></literal> to delimit PHP code, not the <literal><? ?></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 $Id$ 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><pear base dir>/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>&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>&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>&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>&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>&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>&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>&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ãããã¾ãã¯ã¦ã¼ã¶ã®ãã¹ãã¢ãã¬ã¹ã«ããã¦ã¼ ã¶ã®ãã©ã¦ã¶ã¨è¨èªã®äº¤æ¸ãè¡ãã¾ãã è¨èªã³ã¼ãã¯é常ãï¼ã¤ã®å½ã®ã¿ã§è©±ããã¦ããè¨èªã®å ´åã¯ã"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> &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>&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 = &Log::singleton() </literal>syntax. Without the ampersand (&) 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ã追å ãã度ã«ï¼åº¦ã³ã¼ã« ããã¾ãããã®é¢æ°ã¯ã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>ã¯ã©ã¹ã®ï¼ã¤ã®ä½¿ç¨ ããå¿ è¦ãããã¾ãããã®é¢æ°ã¯å¼æ°ãï¼ã¤ã ãã¨ããããã¯ããã©ã¡ã¼ ã¿ã®é£æ³é åã§ãããããã®ãã©ã¡ã¼ã¿ã¯ã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> ãããã¤ãã®å¿ è¦ãªããããçæããããã§ãããã®é¢æ°ã¯ã弿°ãï¼ ã¤ã ãã¨ããããã¯ãè¿ããããããã®é£æ³é åã«ãå«ã¾ãã¾ãã ãã®é åã®ãã¼ã¯ãããå(ä¾ 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> ãã¹ãã©ã¯ã¿ãæ£ããåä½ããããã«ã以ä¸ã®ããã«"=& 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 < 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>ã«è¨å®ãã¦ãã¾ãã(ï¼çªç®ã®ã ã©ã¡ã¼ã¿ã¨ãã¦)ã¨ã©ã¼ã¢ã¼ãã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 -->