cvs: phpdoc /ja/appendices migration4.xml /ja/functions com.xml dbx.xml fbsql.xml math.xml misc.xml oci8.xml pdf.xml var.xml xml.xml /ja/language
oop.xml /ja/pear standards.xml

From: Date: Sun, 20 May 2001 07:43:03 +0000
Subject: cvs: phpdoc /ja/appendices migration4.xml /ja/functions com.xml dbx.xml fbsql.xml math.xml misc.xml oci8.xml pdf.xml var.xml xml.xml /ja/language
oop.xml /ja/pear standards.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969335443@lists.php.net to get a copy of this message
hirokawa Sun May 20 00:43:03 2001 EDT Modified files: /phpdoc/ja/appendices migration4.xml /phpdoc/ja/functions com.xml dbx.xml fbsql.xml math.xml misc.xml oci8.xml pdf.xml var.xml xml.xml /phpdoc/ja/language oop.xml /phpdoc/ja/pear standards.xml Log: updated translation.

Index: phpdoc/ja/appendices/migration4.xml diff -u phpdoc/ja/appendices/migration4.xml:1.2 phpdoc/ja/appendices/migration4.xml:1.3 --- phpdoc/ja/appendices/migration4.xml:1.2 Tue Mar 13 14:59:45 2001 +++ phpdoc/ja/appendices/migration4.xml Sun May 20 00:43:01 2001 @@ -202,7 +202,7 @@ </section> <section> - <title>推奨されない関数と拡張Deprecate functions and extensions</title> + <title>推奨されない関数と拡張</title> <para> Adabas および Solid データベース拡張は、もはや推奨されません。 今後は、unified ODBC 拡張を代わりに使用して下さい。 Index: phpdoc/ja/functions/com.xml diff -u phpdoc/ja/functions/com.xml:1.5 phpdoc/ja/functions/com.xml:1.6 --- phpdoc/ja/functions/com.xml:1.5 Thu Jan 4 22:29:04 2001 +++ phpdoc/ja/functions/com.xml Sun May 20 00:43:01 2001 @@ -1,13 +1,233 @@ <reference id="ref.com"> <title>Windows用のCOMサポート関数</title> <titleabbrev>COM</titleabbrev> - + <partintro> <simpara> 以下の関数は、Windows版のPHPでのみ利用可能です。これらの関数は、 PHP4で追加されました。 </simpara> </partintro> + + <refentry id="class.com"> + <refnamediv> + <refname>COM</refname> + <refpurpose>COM class</refpurpose> + </refnamediv> + <refsynopsisdiv> + <synopsis>$obj = new <classname>COM</classname>("server.object")</synopsis> + </refsynopsisdiv> + <refsect1 id="class.com.class"> + <title>説明</title> + <simpara> + COM クラスは、PHPスクリプトに統合された (D)COMコンポーネントのフ + レームワークを提供します。 + </simpara> + </refsect1> + <refsect1 id="class.com.constructor"> + <title>メソッド</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>COM::COM</function></funcdef> + <paramdef>string <parameter>module_name</parameter></paramdef> + <paramdef>string + <parameter><optional>server_name</optional></parameter> + </paramdef> + <paramdef>int + <parameter><optional>codepage</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + COM クラスのコンストラクタ。 パラメータ: + <variablelist> + <varlistentry><term>module_name</term> + <listitem> + <simpara> + リクエストされたコンポーネントの名前またはクラスID。 + </simpara> + </listitem> + </varlistentry> + <varlistentry><term>server_name</term> + <listitem> + <simpara> + コンポーネントを取得するDCOMサーバの名前。 + <literal>NULL</literal>の場合には、 + <literal>localhost</literal>が指定されたと仮定されます。 + DCOMを使用するためには、<filename>php.ini</filename>で + <constant>com.allow_dcom</constant> を + <literal>TRUE</literal>に設定してある必要があります。 + </simpara> + </listitem> + </varlistentry> + <varlistentry><term>codepage</term> + <listitem> + <simpara> + PHPの文字列のUNICODE文字列への変換およびその逆変換で使用され + るコードページを指定します。使用可能な値は、 + <constant>CP_ACP</constant>, <constant>CP_MACCP</constant>, + <constant>CP_OEMCP</constant>, + <constant>CP_SYMBOL</constant>, + <constant>CP_THREAD_ACP</constant>, + <constant>CP_UTF7</constant>, <constant>CP_UTF8</constant>で + す。 + </simpara> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + <example id="example.com1"> + <title>COM の例 (1)</title> + <programlisting role="php"> +// Wordを起動 +$word = new COM("word.application") or die("Unable to instanciate Word"); +print "Loaded Word, version {$word->Version}\n"; + +// 前面に表示 +$word->Visible = 1; + +// 空のドキュメントをオープン +$word->Documents->Add(); + +// 何か単純な作業をする +$word->Selection->TypeText("This is a test..."); +$word->Documents[1]->SaveAs("Useless test.doc"); + +// Wordを閉じる +$word->Quit(); + +// オブジェクトを開放 +$word->Release(); +$word = null; + </programlisting> + </example> + </para> + <para> + <example id="example.com2"> + <title>COM の例 (2)</title> + <programlisting role="php"> +$conn = new COM("ADODB.Connection") or die("Cannot start ADO"); +$conn->Open("Provider=SQLOLEDB; Data Source=localhost; +Initial Catalog=database; User ID=user; Password=password"); + +$rs = $conn->Execute("SELECT * FROM sometable"); // Recordset + +$num_columns = $rs->Fields->Count(); +echo $num_columns . "\n"; + +for ($i=0; $i < $num_columns; $i++) +{ + $fld[$i] = $rs->Fields($i); +} + +$rowcount = 0; +while (!$rs->EOF) +{ + for ($i=0; $i < $num_columns; $i++) + { + echo $fld[$i]->value . "\t"; + } + echo "\n"; + $rowcount++; // 行カウンタを増やす + $rs->MoveNext(); +} + +$rs->Close(); +$conn->Close(); + +$rs->Release(); +$conn->Release(); + +$rs = null; +$conn = null; + </programlisting> + </example> + </para> + </refsect1> + </refentry> + + <refentry id="class.variant"> + <refnamediv> + <refname>VARIANT</refname> + <refpurpose>VARIANT クラス</refpurpose> + </refnamediv> + <refsynopsisdiv> + <synopsis>$vVar = new <classname>VARIANT</classname>($var)</synopsis> + </refsynopsisdiv> + <refsect1 id="class.variant.class"> + <title>説明</title> + <simpara> + VARIANT構造体に変数をラップするための簡単なコンテナクラス。 + </simpara> + </refsect1> + <refsect1 id="class.variant.constructor"> + <title>メソッド</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>VARIANT::VARIANT</function></funcdef> + <paramdef>mixed + <parameter><optional>value</optional></parameter> + </paramdef> + <paramdef>int + <parameter><optional>type</optional></parameter> + </paramdef> + <paramdef>int + <parameter><optional>codepage</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + <para> + VARIANT クラスのコンストラクタ。 パラメータ: + <variablelist> + <varlistentry><term>value</term> + <listitem> + <simpara> + 初期値。省略した場合には、VT_EMPTYオブジェクトが作成されます。 + </simpara> + </listitem> + </varlistentry> + <varlistentry><term>type</term> + <listitem> + <simpara> + VARIANTオブジェクトのcontent型を指定します。使用可能な値は、 + <constant>VT_UI1</constant>, <constant>VT_UI2</constant>, + <constant>VT_UI4</constant>, <constant>VT_I1</constant>, + <constant>VT_I2</constant>, <constant>VT_I4</constant>, + <constant>VT_R4</constant>, <constant>VT_R8</constant>, + <constant>VT_INT</constant>, <constant>VT_UINT</constant>, + <constant>VT_BOOL</constant>, <constant>VT_ERROR</constant>, + <constant>VT_CY</constant>, <constant>VT_DATE</constant>, + <constant>VT_BSTR</constant>, + <constant>VT_DECIMAL</constant>, + <constant>VT_UNKNOWN</constant>, + <constant>VT_DISPATCH</constant>, + <constant>VT_VARIANT</constant>です。これらの値は相互に排他的 + ですが、値があることを指定するために + <constant>VT_BYREF</constant>を組み合わせることが可能です。 + 省略された場合には、<parameter>value</parameter> の型が使用さ + れます。その他の情報については、MSDNライブラリを参照下さい。 + </simpara> + </listitem> + </varlistentry> + <varlistentry><term>codepage</term> + <listitem> + <simpara> + PHPの文字列のUNICODE文字列への変換およびその逆変換で使用され + るコードページを指定します。使用可能な値は、 + <constant>CP_ACP</constant>, <constant>CP_MACCP</constant>, + <constant>CP_OEMCP</constant>, + <constant>CP_SYMBOL</constant>, + <constant>CP_THREAD_ACP</constant>, + <constant>CP_UTF7</constant>, <constant>CP_UTF8</constant>で + す。 + </simpara> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + </refentry> <refentry id="function.com-load"> <refnamediv> @@ -27,12 +247,22 @@ <replaceable><optional>server name</optional></replaceable> </parameter> </paramdef> + <paramdef>int + <parameter> + <optional>codepage</optional> + </parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> <function>com_load</function>は、新規のCOMコンポーネントを作成し、 このコンポーネントへのリファレンスを返します。失敗した場合に <literal>false</literal>を返します。 + Possible values for <parameter>codepage</parameter> are + <constant>CP_ACP</constant>, <constant>CP_MACCP</constant>, + <constant>CP_OEMCP</constant>, <constant>CP_SYMBOL</constant>, + <constant>CP_THREAD_ACP</constant>, <constant>CP_UTF7</constant> + and <constant>CP_UTF8</constant>. </para> </refsect1> </refentry> @@ -180,10 +410,50 @@ </funcsynopsis> <para> <parameter>com_object</parameter>が指すCOMコンポーネントの - <parameter>property</parameter>の値を設定します。 - <parameter>property</parameter>が設定されている場合に - <literal>true</literal>を返します。エラー時に - <literal>false</literal>を返します。 + <parameter>property</parameter>の値を設定します。成功時に新規に設 + 定された値、エラーの場合に<literal>false</literal>を返します。 + </para> + </refsect1> + </refentry> + + <refentry id="function.com-addref"> + <refnamediv> + <refname>com_addref</refname> + <refpurpose> + コンポーネントリファレンスカウンタを増やす + </refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>com_addref</function></funcdef> + <void/> + </funcprototype> + </funcsynopsis> + <para> + コンポーネントリファレンスカウンタを増やします。 + </para> + </refsect1> + </refentry> + + <refentry id="function.com-release"> + <refnamediv> + <refname>com_release</refname> + <refpurpose> + コンポーネントリファレンスカウンタを減らす + </refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>com_release</function></funcdef> + <void/> + </funcprototype> + </funcsynopsis> + <para> + コンポーネントリファレンスカウンタを減らします。 </para> </refsect1> </refentry> Index: phpdoc/ja/functions/dbx.xml diff -u phpdoc/ja/functions/dbx.xml:1.3 phpdoc/ja/functions/dbx.xml:1.4 --- phpdoc/ja/functions/dbx.xml:1.3 Sat May 5 21:54:00 2001 +++ phpdoc/ja/functions/dbx.xml Sun May 20 00:43:01 2001 @@ -214,7 +214,7 @@ </para> <para> Microsoft SQL Serverに関するエラーメッセージは、実際には - mssql_get_last_message 関数の結果となります。 + <function>mssql_get_last_message</function> 関数の結果となります。 </para> </note> </refsect1> Index: phpdoc/ja/functions/fbsql.xml diff -u phpdoc/ja/functions/fbsql.xml:1.1 phpdoc/ja/functions/fbsql.xml:1.2 --- phpdoc/ja/functions/fbsql.xml:1.1 Sat May 5 21:54:00 2001 +++ phpdoc/ja/functions/fbsql.xml Sun May 20 00:43:01 2001 @@ -1,5 +1,5 @@ <reference id="ref.fbsql"> - <title>FrontBase 関数</title> + <title>FrontBase functions</title> <titleabbrev>FrontBase</titleabbrev> <partintro> <simpara> @@ -23,7 +23,9 @@ FrontBase に関するドキュメントは、<ulink url="&url.fbsql.docs;">&url.fbsql.docs;</ulink> から入手可能です。 </simpara> - + <simpara> + Frontbase のサポートは、PHP 4.0.6 で追加されました。 + </simpara> </partintro> <refentry id="function.fbsql-affected-rows"> @@ -92,7 +94,7 @@ <funcsynopsis> <funcprototype> <funcdef>bool <function>fbsql_autocommit</function></funcdef> - <paramdef>int + <paramdef>resource <parameter>link_identifier</parameter> </paramdef> <paramdef>bool @@ -106,6 +108,7 @@ <function>fbsql_autocommit</function> returns the current autocommit status. if the optional OnOff parameter is given the auto commit status will be changed. + </para> </refsect1> </refentry> @@ -120,7 +123,7 @@ <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_change_user</function></funcdef> + <funcdef>resource <function>fbsql_change_user</function></funcdef> <paramdef>string <parameter>user</parameter></paramdef> <paramdef>string <parameter>password</parameter></paramdef> <paramdef>string @@ -141,21 +144,22 @@ optional parameter link_identifier. If a database is specified, this will default or current database after the user has been changed. If the new user and password authorization fails, - the current connected user stays active.</para> + the current connected user stays active. + </para> </refsect1> </refentry> <refentry id="function.fbsql-close"> <refnamediv> <refname>fbsql_close</refname> - <refpurpose>FrontBase 接続を閉じる</refpurpose> + <refpurpose>Close FrontBase connection</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_close</function></funcdef> - <paramdef>int + <funcdef>boolean <function>fbsql_close</function></funcdef> + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -163,7 +167,7 @@ </funcprototype> </funcsynopsis> <para> - Returns: true on success, false on error. + Returns: <literal>TRUE</literal> on success, <literal>FALSE</literal> on error. </para> <para> <function>fbsql_close</function> closes the connection to the FrontBase server that's associated with the specified link @@ -175,17 +179,15 @@ as non-persistent open links are automatically closed at the end of the script's execution. </para> - <note> - </note> <example> - <title>FrontBase close example</title> + <title><function>fbsql_close</function> example</title> <programlisting role="php"> &lt;?php $link = fbsql_connect ("localhost", "_SYSTEM", "secret") or die ("Could not connect"); print ("Connected successfully"); fbsql_close ($link); -?> +?&gt; </programlisting> </example> <para> @@ -198,15 +200,13 @@ <refentry id="function.fbsql-connect"> <refnamediv> <refname>fbsql_connect</refname> - <refpurpose> - FrontBase サーバへの接続をオープンする - </refpurpose> + <refpurpose>Open a connection to a FrontBase Server</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_connect</function></funcdef> + <funcdef>resource <function>fbsql_connect</function></funcdef> <paramdef>string <parameter> <optional>hostname @@ -248,7 +248,7 @@ <function>fbsql_close</function>. </para> <example> - <title>FrontBase connect example</title> + <title><function>fbsql_connect</function> example</title> <programlisting role="php"> &lt;?php @@ -260,7 +260,8 @@ ?&gt; </programlisting> </example> - <para> See also + <para> + See also <function>fbsql_pconnect</function>, and <function>fbsql_close</function>. </para> @@ -270,15 +271,15 @@ <refentry id="function.fbsql-create-db"> <refnamediv> <refname>fbsql_create_db</refname> - <refpurpose>FrontBaseデータベースを作成する</refpurpose> + <refpurpose>Create a FrontBase database</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_create_db</function></funcdef> + <funcdef>bool <function>fbsql_create_db</function></funcdef> <paramdef>string <parameter>database name</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -291,17 +292,17 @@ identifier. </para> <example> - <title>FrontBase create database example</title> + <title><function>fbsql_create_db</function> example</title> <programlisting role="php"> &lt;?php $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") or die ("Could not connect"); if (fbsql_create_db ("my_db")) { - print ("Database created successfully\n"); + print("Database created successfully\n"); } else { - printf ("Error creating database: %s\n", fbsql_error ()); + printf("Error creating database: %s\n", fbsql_error ()); } -?> +?&gt; </programlisting> </example> <para> @@ -313,19 +314,19 @@ <refentry id="function.fbsql-data-seek"> <refnamediv> <refname>fbsql_data_seek</refname> - <refpurpose>内部的な結果ポインタを移動する</refpurpose> + <refpurpose>Move internal result pointer</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_data_seek</function></funcdef> - <paramdef>int <parameter>result_identifier</parameter></paramdef> + <funcdef>bool <function>fbsql_data_seek</function></funcdef> + <paramdef>resource <parameter>result_identifier</parameter></paramdef> <paramdef>int <parameter>row_number</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns: true on success, false on failure. + Returns: <literal>TRUE</literal> on success, <literal>FALSE</literal> on failure. </para> <para> <function>fbsql_data_seek</function> moves the internal row @@ -338,7 +339,7 @@ </para> <example> - <title>FrontBase data seek example</title> + <title><function>fbsql_data_seek</function> example</title> <programlisting role="php"> &lt;?php $link = fbsql_pconnect ("localhost", "_SYSTEM", "secret") @@ -347,7 +348,7 @@ fbsql_select_db ("samp_db") or die ("Could not select database"); - $query = "SELECT last_name, first_name FROM friends"; + $query = "SELECT last_name, first_name FROM friends;"; $result = fbsql_query ($query) or die ("Query failed"); @@ -362,11 +363,11 @@ if(!($row = fbsql_fetch_object ($result))) continue; - printf ("%s %s&lt;BR>\n", $row->last_name, $row->first_name); + printf("%s %s&lt;BR>\n", $row->last_name, $row->first_name); } fbsql_free_result ($result); -?> +?&gt; </programlisting> </example> </refsect1> @@ -375,16 +376,16 @@ <refentry id="function.fbsql-db-query"> <refnamediv> <refname>fbsql_db_query</refname> - <refpurpose>FrontBaseクエリを送信する</refpurpose> + <refpurpose>Send a FrontBase query</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_db_query</function></funcdef> + <funcdef>resource <function>fbsql_db_query</function></funcdef> <paramdef>string <parameter>database</parameter></paramdef> <paramdef>string <parameter>query</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -393,7 +394,7 @@ </funcsynopsis> <para> Returns: A positive FrontBase result identifier to the query result, - or false on error. + or <literal>FALSE</literal> on error. </para> <para> <function>fbsql_db_query</function> selects a database and @@ -412,15 +413,15 @@ <refentry id="function.fbsql-drop-db"> <refnamediv> <refname>fbsql_drop_db</refname> - <refpurpose>FrontBaseデータベースを破棄(削除)する</refpurpose> + <refpurpose>Drop (delete) a FrontBase database</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_drop_db</function></funcdef> + <funcdef>bool <function>fbsql_drop_db</function></funcdef> <paramdef>string <parameter>database_name</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -428,7 +429,7 @@ </funcprototype> </funcsynopsis> <para> - Returns: true on success, false on failure. + Returns: <literal>TRUE</literal> on success, <literal>FALSE</literal> on failure. </para> <para> <function>fbsql_drop_db</function> attempts to drop (remove) an @@ -441,16 +442,15 @@ <refentry id="function.fbsql-errno"> <refnamediv> <refname>fbsql_errno</refname> - <refpurpose> - 直近のFrontBase処理によるエラーメッセージ番号を返す - </refpurpose> + <refpurpose>Returns the numerical value of the error message from previous + FrontBase operation</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>fbsql_errno</function></funcdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -477,9 +477,9 @@ echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; fbsql_select_db("nonexistentdb"); echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; -$conn = fbsql_query("SELECT * FROM nonexistenttable"); +$conn = fbsql_query("SELECT * FROM nonexistenttable;"); echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; -?> +?&gt; </programlisting> </informalexample> </para> @@ -493,16 +493,15 @@ <refentry id="function.fbsql-error"> <refnamediv> <refname>fbsql_error</refname> - <refpurpose> - 直近のFrontBase処理によるエラーメッセージのテキストを返す - </refpurpose> + <refpurpose>Returns the text of the error message from previous + FrontBase operation</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_error</function></funcdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -528,9 +527,9 @@ echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; fbsql_select_db("nonexistentdb"); echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; -$conn = fbsql_query("SELECT * FROM nonexistenttable"); +$conn = fbsql_query("SELECT * FROM nonexistenttable;"); echo fbsql_errno().": ".fbsql_error()."&lt;BR>"; -?> +?&gt; </programlisting> </informalexample> </para> @@ -545,7 +544,7 @@ <refnamediv> <refname>fbsql_fetch_array</refname> <refpurpose> - 連想配列、数値配列、または両方の配列として結果レコードを取得する + Fetch a result row as an associative array, a numeric array, or both. </refpurpose> </refnamediv> <refsect1> @@ -553,7 +552,7 @@ <funcsynopsis> <funcprototype> <funcdef>array <function>fbsql_fetch_array</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter> <optional>result_type</optional> @@ -562,7 +561,7 @@ </funcprototype> </funcsynopsis> <para> - Returns an array that corresponds to the fetched row, or false + Returns an array that corresponds to the fetched row, or <literal>FALSE</literal> if there are no more rows.</para> <para> <function>fbsql_fetch_array</function> is an extended version of @@ -598,7 +597,7 @@ <function>fbsql_fetch_row</function> and <function>fbsql_fetch_assoc</function>. </para> <example> - <title><function>fbsql_fetch_array</function></title> + <title><function>fbsql_fetch_array</function> example</title> <programlisting role="php"> &lt;?php fbsql_connect ($host, $user, $password); @@ -610,7 +609,7 @@ echo "fullname: ".$row[1]."&lt;br>\n"; } fbsql_free_result ($result); -?> +?&gt; </programlisting> </example> </refsect1> @@ -620,7 +619,7 @@ <refnamediv> <refname>fbsql_fetch_assoc</refname> <refpurpose> - 連想配列として結果レコードを取得する + Fetch a result row as an associative array </refpurpose> </refnamediv> <refsect1> @@ -628,12 +627,12 @@ <funcsynopsis> <funcprototype> <funcdef>array <function>fbsql_fetch_assoc</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> Returns an associative array that corresponds to the fetched row, - or false if there are no more rows.</para> + or <literal>FALSE</literal> if there are no more rows.</para> <para> <function>fbsql_fetch_assoc</function> is equivalent to calling <function>fbsql_fetch_array</function> with FBSQL_ASSOC for the @@ -659,7 +658,7 @@ <function>fbsql_fetch_row</function> and <function>fbsql_fetch_array</function>. </para> <example> - <title><function>fbsql_fetch_assoc</function></title> + <title><function>fbsql_fetch_assoc</function> example</title> <programlisting role="php"> &lt;?php fbsql_connect ($host, $user, $password); @@ -669,7 +668,7 @@ echo $row["fullname"]; } fbsql_free_result ($result); -?> +?&gt; </programlisting> </example> </refsect1> @@ -679,7 +678,7 @@ <refnamediv> <refname>fbsql_fetch_field</refname> <refpurpose> - 結果からカラム情報を取得し、オブジェクトとして返す + Get column information from a result and return as an object </refpurpose> </refnamediv> <refsect1> @@ -687,7 +686,7 @@ <funcsynopsis> <funcprototype> <funcdef>object <function>fbsql_fetch_field</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter> <optional>field_offset</optional> @@ -735,7 +734,7 @@ </itemizedlist> </para> <example> - <title><function>fbsql_fetch_field</function></title> + <title><function>fbsql_fetch_field</function> example</title> <programlisting role="php"> &lt;?php fbsql_connect ($host, $user, $password) @@ -760,7 +759,7 @@ $i++; } fbsql_free_result ($result); -?> +?&gt; </programlisting> </example> <para> @@ -773,7 +772,7 @@ <refnamediv> <refname>fbsql_fetch_lengths</refname> <refpurpose> - 結果の各出力の長さを得る + Get the length of each output in a result </refpurpose> </refnamediv> <refsect1> @@ -781,16 +780,15 @@ <funcsynopsis> <funcprototype> <funcdef>array <function>fbsql_fetch_lengths</function></funcdef> - <paramdef>int - <parameter> - <optional>result</optional> - </parameter> + <paramdef>resource + <parameter><optional>result</optional></parameter> + </paramdef> </funcprototype> </funcsynopsis> <para> Returns: An array that corresponds to the lengths of each field in the last row fetched by <function>fbsql_fetch_row</function>, - or false on error. + or <literal>FALSE</literal> on error. </para> <para> <function>fbsql_fetch_lengths</function> stores the lengths of @@ -809,14 +807,14 @@ <refentry id="function.fbsql-fetch-object"> <refnamediv> <refname>fbsql_fetch_object</refname> - <refpurpose>オブジェクトとして結果レコードを取得する</refpurpose> + <refpurpose>Fetch a result row as an object</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>object <function>fbsql_fetch_object</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter> <optional>result_type</optional> @@ -826,7 +824,7 @@ </funcsynopsis> <para> Returns an object with properties that correspond to the fetched - row, or false if there are no more rows. + row, or <literal>FALSE</literal> if there are no more rows. </para> <para> <function>fbsql_fetch_object</function> is similar to @@ -856,7 +854,7 @@ echo $row->fullname; } fbsql_free_result ($result); -?> +?&gt; </programlisting> </example> </para> @@ -870,18 +868,18 @@ <refentry id="function.fbsql-fetch-row"> <refnamediv> <refname>fbsql_fetch_row</refname> - <refpurpose>数値配列として結果レコードを得る</refpurpose> + <refpurpose>Get a result row as an enumerated array</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>array <function>fbsql_fetch_row</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - Returns: An array that corresponds to the fetched row, or false + Returns: An array that corresponds to the fetched row, or <literal>FALSE</literal> if there are no more rows. </para> <para> @@ -892,7 +890,7 @@ </para> <para> Subsequent call to <function>fbsql_fetch_row</function> would - return the next row in the result set, or false if there are no + return the next row in the result set, or <literal>FALSE</literal> if there are no more rows. </para> <para> @@ -909,7 +907,7 @@ <refnamediv> <refname>fbsql_field_flags</refname> <refpurpose> - 結果において指定したフィールドに関するフラグを得る + Get the flags associated with the specified field in a result </refpurpose> </refnamediv> <refsect1> @@ -917,7 +915,7 @@ <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_field_flags</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -934,7 +932,7 @@ <refnamediv> <refname>fbsql_field_name</refname> <refpurpose> - 結果において指定したフィールドの名前を得る + Get the name of the specified field in a result </refpurpose> </refnamediv> <refsect1> @@ -942,7 +940,7 @@ <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_field_name</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_index</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -993,7 +991,7 @@ <refnamediv> <refname>fbsql_field_len</refname> <refpurpose> - 指定したフィールドの長さを得る + Returns the length of the specified field </refpurpose> </refnamediv> <refsect1> @@ -1001,7 +999,7 @@ <funcsynopsis> <funcprototype> <funcdef>int <function>fbsql_field_len</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -1016,15 +1014,15 @@ <refnamediv> <refname>fbsql_field_seek</refname> <refpurpose> - 指定したフィールドオフセットに結果ポインタを設定する + Set result pointer to a specified field offset </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_field_seek</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <funcdef>bool <function>fbsql_field_seek</function></funcdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -1044,7 +1042,7 @@ <refnamediv> <refname>fbsql_field_table</refname> <refpurpose> - 指定したフィールドがあるテーブルの名前を得る + Get name of the table the specified field is in </refpurpose> </refnamediv> <refsect1> @@ -1052,12 +1050,13 @@ <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_field_table</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> <para> - 指定したフィールドがあるテーブルの名前を返します。 + Returns the name of the table that the specifed field is + in. </para> </refsect1> </refentry> @@ -1066,7 +1065,7 @@ <refnamediv> <refname>fbsql_field_type</refname> <refpurpose> - 結果の中で指定したフィールドの型を得る + Get the type of the specified field in a result </refpurpose> </refnamediv> <refsect1> @@ -1074,7 +1073,7 @@ <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_field_type</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>field_offset</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -1086,13 +1085,13 @@ detailed in the <ulink url="&url.fbsql.docs;">FrontBase documentation</ulink>. <example> - <title>fbsql field types</title> + <title><function>fbsql_field_type</function> example</title> <programlisting role="php"> &lt;?php -fbsql_connect ("localhost:3306"); +fbsql_connect ("localhost", "_SYSTEM", ""); fbsql_select_db ("wisconsin"); -$result = fbsql_query ("SELECT * FROM onek"); +$result = fbsql_query ("SELECT * FROM onek;"); $fields = fbsql_num_fields ($result); $rows = fbsql_num_rows ($result); $i = 0; @@ -1109,7 +1108,7 @@ } fbsql_close(); -?> +?&gt; </programlisting> </example> </para> @@ -1119,13 +1118,13 @@ <refentry id="function.fbsql-free-result"> <refnamediv> <refname>fbsql_free_result</refname> - <refpurpose>結果保持用のメモリを開放する</refpurpose> + <refpurpose>Free result memory</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_free_result</function></funcdef> + <funcdef>bool <function>fbsql_free_result</function></funcdef> <paramdef>int <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -1146,7 +1145,7 @@ <refnamediv> <refname>fbsql_insert_id</refname> <refpurpose> - 直近のINSERT処理で生成されたIDを得る + Get the id generated from the previous INSERT operation </refpurpose> </refnamediv> <refsect1> @@ -1154,7 +1153,7 @@ <funcsynopsis> <funcprototype> <funcdef>int <function>fbsql_insert_id</function></funcdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -1163,14 +1162,14 @@ </funcsynopsis> <para> <function>fbsql_insert_id</function> returns the ID generated for - an AUTO_INCREMENT column by the previous INSERT query using the + an column defined as DEFAULT UNIQUE by the previous INSERT query using the given <parameter>link_identifier</parameter>. If <parameter>link_identifier</parameter> isn't specified, the last opened link is assumed. </para> <para> <function>fbsql_insert_id</function> returns 0 if the previous - query does not generate an AUTO_INCREMENT value. If you need to + query does not generate an DEFAULT UNIQUE value. If you need to save the value for later, be sure to call fbsql_insert_id() immediately after the query that generates the value. </para> @@ -1178,22 +1177,10 @@ <para> The value of the FrontBase SQL function <literal>LAST_INSERT_ID()</literal> always contains the most - recently generated AUTO_INCREMENT value, and is not reset + recently generated DEFAULT UNIQUE value, and is not reset between queries. </para> </note> - <warning> - <para> - <function>fbsql_insert_id</function> converts the return type of - the native FrontBase C API function - <literal>fbsql_insert_id()</literal> to a type of - <literal>long</literal>. If your AUTO_INCREMENT column has - a column type of BIGINT, the value returned by - <function>fbsql_insert_id</function> will be incorrect. - Instead, use the internal FrontBase SQL function - <literal>LAST_INSERT_ID()</literal>. - </para> - </warning> </refsect1> </refentry> @@ -1201,15 +1188,15 @@ <refnamediv> <refname>fbsql_list_dbs</refname> <refpurpose> - FrontBaseサーバで利用可能なデータベースの一覧を得る + List databases available on a FrontBase server </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_list_dbs</function></funcdef> - <paramdef>int + <funcdef>resource <function>fbsql_list_dbs</function></funcdef> + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -1258,16 +1245,16 @@ <refentry id="function.fbsql-list-fields"> <refnamediv> <refname>fbsql_list_fields</refname> - <refpurpose>FrontBase結果フィールドの一覧を得る</refpurpose> + <refpurpose>List FrontBase result fields</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_list_fields</function></funcdef> + <funcdef>resource <function>fbsql_list_fields</function></funcdef> <paramdef>string <parameter>database_name</parameter></paramdef> <paramdef>string <parameter>table_name</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -1322,15 +1309,15 @@ <refentry id="function.fbsql-list-tables"> <refnamediv> <refname>fbsql_list_tables</refname> - <refpurpose>FrontBaseデータベースのテーブル一覧を得る</refpurpose> + <refpurpose>List tables in a FrontBase database</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_list_tables</function></funcdef> + <funcdef>resource <function>fbsql_list_tables</function></funcdef> <paramdef>string <parameter>database</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -1347,17 +1334,61 @@ </refsect1> </refentry> + <refentry id="function.fbsql-next-result"> + <refnamediv> + <refname>fbsql_next_result</refname> + <refpurpose>Move the internal result pointer to the next result</refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>bool + <function>fbsql_next_result</function> + </funcdef> + <paramdef>int <parameter>result_id</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + When sending more than one SQL statement to the server or executing a stored procedure + with multiple results will cause the server to return multiple result sets. + This function will test for additional results available form the server. if an + additional result set exists it will free the existing result set and prepare to + fetch the wors from the new result set. + The function will return <literal>TRUE</literal> if an additional result set was + available or <literal>FALSE</literal> othervise. + </para> + <example> + <title><function>fbsql_next_result</function> example</title> + <programlisting role="php"> +&lt;?php + $link = fbsql_connect ("localhost", "_SYSTEM", "secret"); + fbsql_select_db("MyDB", $link); + $SQL = "Select * from table1; select * from table2;"; + $rs = fbsql_query($SQL, $link); + do { + while ($row = fbsql_fetch_row($rs)) { + } + } while (fbsql_next_result($rs)); + fbsql_free_result($rs); + fbsql_close ($link); +?&gt; + </programlisting> + </example> + </refsect1> + </refentry> + <refentry id="function.fbsql-num-fields"> <refnamediv> <refname>fbsql_num_fields</refname> - <refpurpose>結果のフィールド数を得る</refpurpose> + <refpurpose>Get number of fields in result</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>fbsql_num_fields</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> @@ -1376,14 +1407,14 @@ <refentry id="function.fbsql-num-rows"> <refnamediv> <refname>fbsql_num_rows</refname> - <refpurpose>結果のレコード数を得る</refpurpose> + <refpurpose>Get number of rows in result</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>int <function>fbsql_num_rows</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> </funcprototype> </funcsynopsis> <para> @@ -1399,7 +1430,7 @@ $link = fbsql_connect("localhost", "username", "password"); fbsql_select_db("database", $link); -$result = fbsql_query("SELECT * FROM table1", $link); +$result = fbsql_query("SELECT * FROM table1;", $link); $num_rows = fbsql_num_rows($result); echo "$num_rows Rows\n"; @@ -1422,21 +1453,16 @@ <refnamediv> <refname>fbsql_pconnect</refname> <refpurpose> - FrontBaseサーバへの持続的な接続をオープンする + Open a persistent connection to a FrontBase Server </refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_pconnect</function></funcdef> + <funcdef>resource <function>fbsql_pconnect</function></funcdef> <paramdef>string - <parameter> - <optional>hostname - <optional>:port</optional> - <optional>:/path/to/socket</optional> - </optional> - </parameter> + <parameter><optional>hostname</optional></parameter> </paramdef> <paramdef>string <parameter><optional>username</optional></parameter> @@ -1448,25 +1474,22 @@ </funcsynopsis> <para> Returns: A positive FrontBase persistent link identifier on success, - or false on error. + or <literal>FALSE</literal> on error. </para> <para> <function>fbsql_pconnect</function> establishes a connection to a FrontBase server. The following defaults are assumed for - missing optional parameters: <parameter>host:port</parameter> = - 'localhost:3306', <parameter>username</parameter> = name of the - user that owns the server process and - <parameter>password</parameter> = empty password. + missing optional parameters: <parameter>host</parameter> = + 'localhost', <parameter>username</parameter> = "_SYSTEM" + and <parameter>password</parameter> = empty password. </para> <para> - The hostname string can also include a port - number. eg. &quot;hostname:port&quot; or a path to a socket - eg. &quot;:/path/to/socket&quot; for the localhost. - </para> - <para> <function>fbsql_pconnect</function> acts very much like <function>fbsql_connect</function> with two major differences. </para> + <para> + To set Frontbase server port number, use <function>fbsql_select_db</function>. + </para> <para> First, when connecting, the function would first try to find a (persistent) link that's already open with the same host, @@ -1487,15 +1510,15 @@ <refentry id="function.fbsql-query"> <refnamediv> <refname>fbsql_query</refname> - <refpurpose>FrontBaseクエリを送信する</refpurpose> + <refpurpose>Send a FrontBase query</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_query</function></funcdef> + <funcdef>resource <function>fbsql_query</function></funcdef> <paramdef>string <parameter>query</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter><optional>link_identifier</optional></parameter> </paramdef> </funcprototype> @@ -1511,27 +1534,27 @@ </para> <note> <para> - The query string should not end with a semicolon. + The query string shall always end with a semicolon. </para> </note> <para> - <function>fbsql_query</function> returns TRUE (non-zero) or FALSE + <function>fbsql_query</function> returns <literal>TRUE</literal> (non-zero) or <literal>FALSE</literal> to indicate whether or not the query succeeded. A return value - of TRUE means that the query was legal and could be executed by + of <literal>TRUE</literal> means that the query was legal and could be executed by the server. It does not indicate anything about the number of rows affected or returned. It is perfectly possible for a query to succeed but affect no rows or return no rows. </para> <para> The following query is syntactically invalid, so - <function>fbsql_query</function> fails and returns FALSE: + <function>fbsql_query</function> fails and returns <literal>FALSE</literal>: <example> - <title><function>fbsql_query</function></title> + <title><function>fbsql_query</function> example</title> <programlisting role="php"> &lt;?php $result = fbsql_query ("SELECT * WHERE 1=1") or die ("Invalid query"); -?> +?&gt; </programlisting> </example> </para> @@ -1539,19 +1562,19 @@ The following query is semantically invalid if <literal>my_col</literal> is not a column in the table <literal>my_tbl</literal>, so <function>fbsql_query</function> - fails and returns FALSE: + fails and returns <literal>FALSE</literal>: <example> - <title><function>fbsql_query</function></title> + <title><function>fbsql_query</function> example</title> <programlisting role="php"> &lt;?php $result = fbsql_query ("SELECT my_col FROM my_tbl") or die ("Invalid query"); -?> +?&gt; </programlisting> </example> </para> <para> - <function>fbsql_query</function> will also fail and return FALSE + <function>fbsql_query</function> will also fail and return <literal>FALSE</literal> if you don't have permission to access the table(s) referenced by the query. </para> @@ -1593,7 +1616,7 @@ <funcsynopsis> <funcprototype> <funcdef>mixed <function>fbsql_result</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>row</parameter></paramdef> <paramdef>mixed <parameter> @@ -1635,15 +1658,15 @@ <refentry id="function.fbsql-select-db"> <refnamediv> <refname>fbsql_select_db</refname> - <refpurpose>FrontBaseデータベースを選択する</refpurpose> + <refpurpose>Select a FrontBase database</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>int <function>fbsql_select_db</function></funcdef> + <funcdef>resource <function>fbsql_select_db</function></funcdef> <paramdef>string <parameter>database_name</parameter></paramdef> - <paramdef>int + <paramdef>resource <parameter> <optional>link_identifier</optional> </parameter> @@ -1651,7 +1674,7 @@ </funcprototype> </funcsynopsis> <para> - Returns: true on success, false on error. + Returns: <literal>TRUE</literal> on success, <literal>FALSE</literal> on error. </para> <para> <function>fbsql_select_db</function> sets the current active @@ -1662,6 +1685,14 @@ called, and use it. </para> <para> + The client contacts FBExec to obtain the port number to use for + the connection to the database. if the database name is a number + the system will use that as a port number and it will not ask + FBExec for the port number. + The FrontBase server can be stared as + FRontBase -FBExec=No -port=&lt;port number&gt; &lt;database name&gt;. + </para> + <para> Every subsequent call to <function>fbsql_query</function> will be made on the active database. </para> @@ -1676,14 +1707,14 @@ <refentry id="function.fbsql-tablename"> <refnamediv> <refname>fbsql_tablename</refname> - <refpurpose>指定したフィールドのテーブル名を得る</refpurpose> + <refpurpose>Get table name of field</refpurpose> </refnamediv> <refsect1> <title>説明</title> <funcsynopsis> <funcprototype> <funcdef>string <function>fbsql_tablename</function></funcdef> - <paramdef>int <parameter>result</parameter></paramdef> + <paramdef>resource <parameter>result</parameter></paramdef> <paramdef>int <parameter>i</parameter></paramdef> </funcprototype> </funcsynopsis> @@ -1694,10 +1725,10 @@ <function>fbsql_num_rows</function> function may be used to determine the number of tables in the result pointer. <example> - <title><function>fbsql_tablename</function> Example</title> + <title><function>fbsql_tablename</function> example</title> <programlisting role="php"> &lt;?php -fbsql_connect ("localhost:3306"); +fbsql_connect ("localhost", "_SYSTEM", ""); $result = fbsql_list_tables ("wisconsin"); $i = 0; while ($i &lt; fbsql_num_rows ($result)) { @@ -1705,7 +1736,7 @@ echo $tb_names[$i] . "&lt;BR>"; $i++; } -?> +?&gt; </programlisting> </example> </para> @@ -1715,7 +1746,7 @@ <refentry id="function.fbsql-warnings"> <refnamediv> <refname>fbsql_warnings</refname> - <refpurpose>FrontBaseの警告を有効または無効にする</refpurpose> + <refpurpose>Enable or disable FrontBase warnings</refpurpose> </refnamediv> <refsect1> <title>説明</title> @@ -1730,7 +1761,7 @@ </funcprototype> </funcsynopsis> <para> - Returns: true if warnings is turned on otherwise false. + Returns <literal>TRUE</literal> if warnings is turned on otherwise <literal>FALSE</literal>. </para> <para> <function>fbsql_warnings</function> enables or disables FrontBase Index: phpdoc/ja/functions/math.xml diff -u phpdoc/ja/functions/math.xml:1.17 phpdoc/ja/functions/math.xml:1.18 --- phpdoc/ja/functions/math.xml:1.17 Sat May 5 22:22:49 2001 +++ phpdoc/ja/functions/math.xml Sun May 20 00:43:01 2001 @@ -840,6 +840,24 @@ えられた文字列を使い、小数部の前のドット(".")の代わりに <parameter>dec_point</parameter>で与えられた文字列を使います。 </para> + <para> + 例えば、フランス語表記では通常小数点以下は2桁とし、カンマ(',')を + 小数部の区切り文字、スペースを1000の位毎の区切り文字として使用し + ます。これは、次のように行います。 + <informalexample> + <programlisting role="php"> +&lt;?php + $nombre = 1234.56; + // 英語表記 (デフォルト) + $english_format_number = number_format($nombre); + // 1,234.56 + // フランス語表記 + $nombre_format_francais = number_format($nombre, 2, ',', ' '); + // 1 234,56 +?&gt; + </programlisting> + </informalexample> + </para> </refsect1> </refentry> Index: phpdoc/ja/functions/misc.xml diff -u phpdoc/ja/functions/misc.xml:1.17 phpdoc/ja/functions/misc.xml:1.18 --- phpdoc/ja/functions/misc.xml:1.17 Sun Mar 18 08:36:45 2001 +++ phpdoc/ja/functions/misc.xml Sun May 20 00:43:01 2001 @@ -47,9 +47,9 @@ </funcsynopsis> <simpara> 接続ステータスのビットフィールドを返します。 - 詳細な説明に関しては、<link linkend="features">機能 </link>に関する章の - <link linkend="features.connection-handling">接続処理</link> - に関する記述を参照下さい。 + 詳細な説明に関しては、<link linkend="features">機能 </link>に関す + る章の<link linkend="features.connection-handling">接続処理 + </link>に関する記述を参照下さい。 </simpara> </refsect1> </refentry> @@ -69,10 +69,18 @@ </funcsynopsis> <simpara> スクリプトがタイムアウトした場合にtrueを返します。 - 詳細な説明に関しては、<link linkend="features">機能 </link>に関する章の - <link linkend="features.connection-handling">接続処理</link> - に関する記述を参照下さい。 </simpara> + <warning> + <title>過去の関数</title> + <simpara> + この関数は、過去のものであり、4.0.5以降には存在しません。 + </simpara> + </warning> + <simpara> + 詳細な説明に関しては、<link linkend="features">機能 </link>に関す + る章の<link linkend="features.connection-handling">接続処理 + </link>に関する記述を参照下さい。 + </simpara> </refsect1> </refentry> @@ -217,8 +225,18 @@ </funcprototype> </funcsynopsis> <para> - <parameter>name</parameter> で指定した名前の定数が定義されている場合に - true、その他の場合にfalseを返します。 + <parameter>name</parameter> で指定した名前の定数が定義されている + 場合にtrue、その他の場合にfalseを返します。 + <example> + <title>定数のチェック</title> + <programlisting role="php"> +&lt;?php +if (defined("CONSTANT")){ // 引用符で括られている必要があります + echo CONSTANT; // + } +?&gt; + </programlisting> + </example> </para> <para> <function>define</function>, @@ -268,7 +286,7 @@ </para> <para> <example> - <title>関数を使用する <function>die</function> の例</title> + <title>関数を使用する<function>die</function>の例</title> <programlisting role="php"> &lt;?php @@ -296,7 +314,7 @@ <refentry id="function.eval"> <refnamediv> <refname>eval</refname> - <refpurpose>文字列を PHP コードとして評価する</refpurpose> + <refpurpose>文字列をPHPコードとして評価する</refpurpose> </refnamediv> <refsect1> <title>説明</title> @@ -611,7 +629,8 @@ <refnamediv> <refname>ignore_user_abort</refname> <refpurpose> - クライアント接続が断となった時にスクリプトの実行を中断するかどうかを設定する + クライアント接続が断となった時にスクリプトの実行を中断するかどう + かを設定する </refpurpose> </refnamediv> <refsect1> @@ -852,62 +871,6 @@ </refsect1> </refentry> - <refentry id="function.serialize"> - <refnamediv> - <refname>serialize</refname> - <refpurpose> - 値の保存可能な表現を生成する - </refpurpose> - </refnamediv> - <refsect1> - <title>説明</title> - <funcsynopsis> - <funcprototype> - <funcdef>string <function>serialize</function></funcdef> - <paramdef>mixed <parameter>value</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - <function>serialize</function> は、<parameter>value</parameter>の - 保存可能なバイトストリーム表現を含む文字列を返します。 - </simpara> - <simpara> - 型や構造を失わずにPHPの値を保存または渡す際に有効です。 - </simpara> - <simpara> - シリアル化された文字列をPHPの値に戻すには、 - <function>unserialize</function>を使用して下さい。 - <function>serialize</function>は型<type>integer</type>, - <type>double</type>,<type>string</type>,<type>array</type> - (多次元),<type>object</type> - (オブジェクトプロパティはシリアル化されますが、メソッドは失われます) - に対応します。 - </simpara> - <para> - <example> - <title><function>serialize</function>の例</title> - <programlisting role="php"> -// $session_data はカレントユーザーのセッション情報を含む多次元配列を -// 保持しています。リクエストの最後にこれをデータベースに保存するために -// serialize() を使用します。 - -$conn = odbc_connect("webdb", "php", "chicken"); -$stmt = odbc_prepare($conn, - "UPDATE sessions SET data = ? WHERE id = ?"); -$sqldata = array(serialize($session_data), $PHP_AUTH_USER); -if (!odbc_execute($stmt, &$sqldata)) { - $stmt = odbc_prepare($conn, - "INSERT INTO sessions (id, data) VALUES(?, ?)"); - if (!odbc_execute($stmt, &$sqldata)) { - /* 何か問題があったようです。Bitch, whine and moan. */ - } -} - </programlisting> - </example> - </para> - </refsect1> - </refentry> - <refentry id="function.show-source"> <refnamediv> <refname>show_source</refname> @@ -978,9 +941,9 @@ <title>説明</title> <funcsynopsis> <funcprototype> - <funcdef>string <function>uniqid</function></funcdef> + <funcdef>int <function>uniqid</function></funcdef> <paramdef>string <parameter>prefix</parameter></paramdef> - <paramdef>boolean + <paramdef>bool <parameter> <replaceable><optional>lcg</optional></replaceable> </parameter> @@ -988,11 +951,11 @@ </funcprototype> </funcsynopsis> <simpara> - <function>uniqid</function>は、ミリ秒単位の現在時刻に基づき - 先頭辞(prefix)を付けたユニークなIDを返します。 - いくつかのホスト上で同時にIDを生成させる場合、 - 全く同じミリ秒のIDが生成されるのを防ぐのにprefixが有用です。 - <parameter>prefix</parameter>には114文字までの長さを指定することができます。 + <function>uniqid</function>は、ミリ秒単位の現在時刻に基づき先頭辞 + (prefix)を付けたユニークなIDを返します。いくつかのホスト上で同 + 時にIDを生成させる場合、全く同じミリ秒のIDが生成されるのを防ぐの + にprefixが有用です。<parameter>prefix</parameter>には114文字まで + の長さを指定することができます。 </simpara> <simpara> オプションの <parameter>lcg</parameter> パラメータが true の場合、 @@ -1006,14 +969,14 @@ </simpara> <note> <simpara> - <parameter>lcg</parameter> パラメータは、 - PHP 4またはPHP 3.0.13以降でのみ使用可能です。 + <parameter>lcg</parameter> パラメータは、PHP 4またはPHP 3.0.13以 + 降でのみ使用可能です。 </simpara> </note> <para> - ユニークなIDまたはトークンが必要な場合、そして、 - ネットワーク経由でユーザーにそのトークンを渡そうとする場合、 - 次の例のようにするのが推奨されます。 + ユニークなIDまたはトークンが必要な場合、そして、ネットワーク経由 + でユーザーにそのトークンを渡そうとする場合(例えば、セッションクッ + キー)、次の例のようにするのが推奨されます。 <informalexample> <programlisting role="php"> $token = md5 (uniqid ("")); // ランダム要素なし @@ -1074,57 +1037,6 @@ </refsect1> </refentry> - <refentry id="function.unserialize"> - <refnamediv> - <refname>unserialize</refname> - <refpurpose>保存用表現から PHP の値を生成する</refpurpose> - </refnamediv> - <refsect1> - <title>説明</title> - <funcsynopsis> - <funcprototype> - <funcdef>mixed <function>unserialize</function></funcdef> - <paramdef>string <parameter>str</parameter></paramdef> - </funcprototype> - </funcsynopsis> - <simpara> - <function>unserialize</function> は、シリアル化された変数 - (<function>serialize</function> を参照) をとり、PHP 変数値に - 戻す変換を行います。変換された値が返されます。その値は、 - <type>integer</type>, <type>double</type>, - <type>string</type>, <type>array</type> , <type>object</type> - とすることが可能です。 - オブジェクトがシリアル化された場合、 - 返り値にそのメソッドは保存されていません。 - </simpara> - <para> - <example> - <title><function>unserialize</function>の例</title> - <programlisting role="php"> -// ここで、データベースから $session_data にセッションデータをロード -// するために unserialize() を使用します。 -// この例は、<function>serialize</function> で記述された例を補足するものです。 - -$conn = odbc_connect("webdb", "php", "chicken"); -$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?"); -$sqldata = array($PHP_AUTH_USER); -if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) { - // 実行または取得が失敗した場合、空の配列で初期化します - $session_data = array(); -} else { - // $tmp[0] にシリアル化されたデータを保持している必要があります。 - $session_data = unserialize($tmp[0]); - if (!is_array($session_data)) { - // 何か問題があったため、空の配列で初期化します。 - $session_data = array(); - } -} - </programlisting> - </example> - </para> - </refsect1> - </refentry> - <refentry id="function.usleep"> <refnamediv> <refname>usleep</refname> Index: phpdoc/ja/functions/oci8.xml diff -u phpdoc/ja/functions/oci8.xml:1.13 phpdoc/ja/functions/oci8.xml:1.14 --- phpdoc/ja/functions/oci8.xml:1.13 Sat May 5 22:22:49 2001 +++ phpdoc/ja/functions/oci8.xml Sun May 20 00:43:01 2001 @@ -1336,8 +1336,8 @@ var_dump($data); } -OCIFreeCursor ($stmt); -OCIFreeStatement ($curs); +OCIFreeStatement ($stmt); +OCIFreeCursor ($curs); OCILogoff ($conn); ?> </programlisting> Index: phpdoc/ja/functions/pdf.xml diff -u phpdoc/ja/functions/pdf.xml:1.21 phpdoc/ja/functions/pdf.xml:1.22 --- phpdoc/ja/functions/pdf.xml:1.21 Wed Mar 28 05:45:34 2001 +++ phpdoc/ja/functions/pdf.xml Sun May 20 00:43:02 2001 @@ -1987,6 +1987,33 @@ </refsect1> </refentry> + <refentry id="function.pdf-setcolor"> + <refnamediv> + <refname>PDF_setcolor</refname> + <refpurpose>塗りつぶし色および輪郭色をCMYKで設定する</refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>void <function>PDF_setcolor</function></funcdef> + <paramdef>int <parameter>pdf object</parameter></paramdef> + <paramdef>string <parameter>type</parameter></paramdef> + <paramdef>string <parameter>colorspace</parameter></paramdef> + <paramdef>double <parameter>c1</parameter></paramdef> + <paramdef>double <parameter>c2</parameter></paramdef> + <paramdef>double <parameter>c3</parameter></paramdef> + <paramdef>double <parameter>c4</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <para> + カレントのカラースペースと色を設定します。 + <parameter>type</parameter>は、"fill", "stroke", "both" のどれか + です。 + </para> + </refsect1> + </refentry> + <refentry id="function.pdf-setdash"> <refnamediv> <refname>pdf_setdash</refname> Index: phpdoc/ja/functions/var.xml diff -u phpdoc/ja/functions/var.xml:1.26 phpdoc/ja/functions/var.xml:1.27 --- phpdoc/ja/functions/var.xml:1.26 Fri Apr 27 19:20:55 2001 +++ phpdoc/ja/functions/var.xml Sun May 20 00:43:02 2001 @@ -791,6 +791,11 @@ オブジェクトに関しても同様の表示形式となります。 </simpara> <simpara> + <function>print_r</function>は、配列ポインタを終端まで移動するこ + とに注意して下さい。ポインタを最初に戻すために + <function>reset</function>を使用して下さい。 + </simpara> + <simpara> <function>print_r</function>を <function>var_dump</function>と比較してみて下さい。 </simpara> @@ -817,6 +822,75 @@ </refsect1> </refentry> + <refentry id="function.serialize"> + <refnamediv> + <refname>serialize</refname> + <refpurpose> + 値の保存可能な表現を生成する + </refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>string <function>serialize</function></funcdef> + <paramdef>mixed <parameter>value</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <function>serialize</function> は、<parameter>value</parameter>の + 保存可能なバイトストリーム表現を含む文字列を返します。 + </simpara> + <simpara> + 型や構造を失わずにPHPの値を保存または渡す際に有効です。 + </simpara> + <simpara> + シリアル化された文字列をPHPの値に戻すには、 + <function>unserialize</function>を使用して下さい。 + <function>serialize</function>は型<type>integer</type>, + <type>double</type>,<type>string</type>,<type>array</type> + (多次元),<type>object</type> + (オブジェクトプロパティはシリアル化されますが、メソッドは失われます) + に対応します。 + </simpara> + <note> + <para> + PHP 3では、メソッドはシリアル化されたオブジェクトを非シリアル化 + する際に保存されません。PHP 4ではこの制限は取り除かれ、プロパティ + とメソッドの両方を保存します。より詳細な情報については、 + <link linkend="language.oop">オブジェクトとクラス</link> の + <link linkend="language.oop.serialization">オブジェクトのシリア + ル化</link>の節を参照下さい。 + </para> + </note> + <para> + <example> + <title><function>serialize</function>の例</title> + <programlisting role="php"> +// $session_data はカレントユーザーのセッション情報を含む多次元配列を +// 保持しています。リクエストの最後にこれをデータベースに保存するために +// serialize() を使用します。 + +$conn = odbc_connect("webdb", "php", "chicken"); +$stmt = odbc_prepare($conn, + "UPDATE sessions SET data = ? WHERE id = ?"); +$sqldata = array(serialize($session_data), $PHP_AUTH_USER); +if (!odbc_execute($stmt, &amp;$sqldata)) { + $stmt = odbc_prepare($conn, + "INSERT INTO sessions (id, data) VALUES(?, ?)"); + if (!odbc_execute($stmt, &amp;$sqldata)) { + /* 何か問題があったようです。Bitch, whine and moan. */ + } +} + </programlisting> + </example> + </para> + <para> + <function>unserialize</function>も参照下さい。 + </para> + </refsect1> + </refentry> + <refentry id="function.settype"> <refnamediv> <refname>settype</refname> @@ -898,6 +972,69 @@ </refsect1> </refentry> + <refentry id="function.unserialize"> + <refnamediv> + <refname>unserialize</refname> + <refpurpose>保存用表現から PHP の値を生成する</refpurpose> + </refnamediv> + <refsect1> + <title>説明</title> + <funcsynopsis> + <funcprototype> + <funcdef>mixed <function>unserialize</function></funcdef> + <paramdef>string <parameter>str</parameter></paramdef> + </funcprototype> + </funcsynopsis> + <simpara> + <function>unserialize</function> は、シリアル化された変数 + (<function>serialize</function> を参照) をとり、PHP 変数値に + 戻す変換を行います。変換された値が返されます。その値は、 + <type>integer</type>, <type>double</type>, + <type>string</type>, <type>array</type> , <type>object</type> + とすることが可能です。オブジェクトがシリアル化された場合、返り値 + にそのメソッドは保存されていません。 + </simpara> + <note> + <para> + PHP 3では、メソッドはシリアル化されたオブジェクトを非シリアル化 + する際に保存されません。PHP 4ではこの制限は取り除かれ、プロパティ + とメソッドの両方を保存します。より詳細な情報については、 + <link linkend="language.oop">オブジェクトとクラス</link> の + <link linkend="language.oop.serialization">オブジェクトのシリア + ル化</link>の節を参照下さい。 + </para> + </note> + <para> + <example> + <title><function>unserialize</function>の例</title> + <programlisting role="php"> +// ここで、データベースから $session_data にセッションデータをロード +// するために unserialize() を使用します。 +// この例は、<function>serialize</function> で記述された例を補足するものです。 + +$conn = odbc_connect("webdb", "php", "chicken"); +$stmt = odbc_prepare($conn, "SELECT data FROM sessions WHERE id = ?"); +$sqldata = array($PHP_AUTH_USER); +if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) { + // 実行または取得が失敗した場合、空の配列で初期化します + $session_data = array(); +} else { + // $tmp[0] にシリアル化されたデータを保持している必要があります。 + $session_data = unserialize($tmp[0]); + if (!is_array($session_data)) { + // 何か問題があったため、空の配列で初期化します。 + $session_data = array(); + } +} + </programlisting> + </example> + </para> + <para> + <function>serialize</function>も参照下さい。 + </para> + </refsect1> + </refentry> + <refentry id="function.unset"> <refnamediv> <refname>unset</refname> Index: phpdoc/ja/functions/xml.xml diff -u phpdoc/ja/functions/xml.xml:1.10 phpdoc/ja/functions/xml.xml:1.11 --- phpdoc/ja/functions/xml.xml:1.10 Thu Jan 4 22:29:05 2001 +++ phpdoc/ja/functions/xml.xml Sun May 20 00:43:02 2001 @@ -396,18 +396,18 @@ } function startElement($parser, $name, $attribs){ - print "&amp;lt;&lt;font color=\"#0000cc\"&gt;$name&lt;/font&gt;"; + print "&amp;lt;&lt;font color=\"&num;0000cc\"&gt;$name&lt;/font&gt;"; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { - print " &lt;font color=\"#009900\"&gt;$k&lt;/font&gt;=\"&lt;font - color=\"#990000\"&gt;$v&lt;/font&gt;\""; + print " &lt;font color=\"&num;009900\"&gt;$k&lt;/font&gt;=\"&lt;font + color=\"&num;990000\"&gt;$v&lt;/font&gt;\""; } } print "&amp;gt;"; } function endElement($parser, $name){ - print "&amp;lt;/&lt;font color=\"#0000cc\"&gt;$name&lt;/font&gt;&amp;gt;"; + print "&amp;lt;/&lt;font color=\"&num;0000cc\"&gt;$name&lt;/font&gt;&amp;gt;"; } function characterData($parser, $data){ @@ -432,7 +432,7 @@ function defaultHandler($parser, $data){ if (substr($data, 0, 1) == "&amp;" &amp;&amp; substr($data, -1, 1) == ";") { - printf('&lt;font color="#aa00aa"&gt;%s&lt;/font&gt;', htmlspecialchars($data)); + printf('&lt;font color="&num;aa00aa"&gt;%s&lt;/font&gt;', htmlspecialchars($data)); } else { printf('&lt;font size="-1"&gt;%s&lt;/font&gt;', htmlspecialchars($data)); } @@ -1059,7 +1059,7 @@ </para> <para> 外部エンティティ宣言の記述用定義に関しては、 - <ulink url="&url.rec-xml;#sec-external-ent">XML 1.0 仕様の 4.2.2 + <ulink url="&url.rec-xml;&num;sec-external-ent">XML 1.0 仕様の 4.2.2 節</ulink>を参照下さい。 </para> <para> @@ -1179,7 +1179,7 @@ > | <parameter>publicId</parameter >}&gt;</programlisting> 表記法宣言の定義に関しては、 - <ulink url="&url.rec-xml;#Notations">XML 1.0 仕様の 4.7 節</ulink> + <ulink url="&url.rec-xml;&num;Notations">XML 1.0 仕様の 4.7 節</ulink> を参照下さい。 </para> <para> Index: phpdoc/ja/language/oop.xml diff -u phpdoc/ja/language/oop.xml:1.7 phpdoc/ja/language/oop.xml:1.8 --- phpdoc/ja/language/oop.xml:1.7 Sat Mar 10 21:56:44 2001 +++ phpdoc/ja/language/oop.xml Sun May 20 00:43:02 2001 @@ -38,11 +38,40 @@ この例は、籠の中の物と籠にアイテムを加えたり除いたりする二つの関数への 連想配列からなる Cart という名前のクラスを定義します。 </para> + + <caution> + <simpara> + 以下の注意書きはPHP 4に関するものです。 + </simpara> + + <simpara> + 名前<literal>stdClass</literal>は、Zendにより内部的に使用され、保 + 存されています。PHPで<literal>stdClass</literal>という名前のクラ + スを使用することはできません。 + </simpara> + + <simpara> + The function names <literal>__sleep</literal> and + <literal>__wakeup</literal> are magical in PHP classes. You + cannot have functions with these names in any of your + classes unless you want the magic functionality associated + with them. See below for more information. + </simpara> + + <simpara> + PHP reserves all function names starting with __ as magical. + It is recommended that you do not use function names with + __ in PHP unless you want some documented magic functionality. + </simpara> + </caution> + <note> <simpara> PHP 4では、変数<literal>var</literal>については定数による初期化の - みが可能です。定数以外で初期化を行う場合にはコンストラクタを使用 - して下さい。 + みが可能です。定数以外で初期化を行う場合には初期化関数が必要です。 + この初期化関数は、オブジェクトがクラスから構築される際に自動的に + コールされます。このような関数はコンストラクタと呼ばれます。(以下 + 参照) </simpara> <informalexample> <programlisting role="php"> @@ -69,32 +98,96 @@ </informalexample> </note> <para> - クラスは型、つまり、実際の変数の雛型です。 - new 演算子により所望の型の変数を作成する必要があります。 + クラスは型、つまり、実際の変数の雛型です。<literal>new</literal>演 + 算子により所望の型の変数を作成する必要があります。 </para> <informalexample> <programlisting role="php"> -$cart = new Cart; -$cart->add_item("10", 1); + $cart = new Cart; + $cart->add_item("10", 1); + + $another_cart = new Cart; + $another_cart->add_item("0815", 3); </programlisting> </informalexample> <para> - この例は、クラス Cart のオブジェクト $cart を作成します。 - オブジェクトの関数 add_item() が番号10 の物を籠に加えるためにコールされ - ています。 + この例は、クラスCartのオブジェクト $cartおよび$another_cartを作成 + します。$cartオブジェクトの関数 add_item()が商品番号10の商品一つが + カートに追加されています。商品番号0815の商品3つが$another_cartに追 + 加されています。 </para> + <para> - クラスは、他のクラスを拡張することにより作成することができます。 - 拡張または派生クラスは、基底クラスの全ての変数と関数、そして、 - 拡張する際の定義により加えられたものを保持しています。 - この定義は、extends キーワードにより行なうことができます。 - 多重継承はサポートされていません。 + Both, $cart and $another_cart, have functions add_item(), + remove_item() and a variable items. These are distinct + functions and variables. You can think of the objects as + something similar to directories in a filesystem. In a + filesystem you can have two different files README.TXT, as + long as they are in different directories. Just like with + directories where you'll have to type the full pathname in + order to reach each file from the toplevel directory, you + have to specify the complete name of the function you want + to call: In PHP terms, the toplevel directory would be the + global namespace, and the pathname separator would be -&gt;. + Thus, the names $cart-&gt;items and $another_cart-&gt;items + name two different variables. Note that the variable is + named $cart-&gt;items, not $cart-&gt;$items, that is, a + variable name in PHP has only a single dollar sign. </para> - + <informalexample> <programlisting role="php"> +// correct, single $ +$cart->items = array("10" => 1); + +// invalid, because $cart->$items becomes $cart->"" +$cart->$items = array("10" => 1); + +// correct, but may or may not be what was intended: +// $cart->$myvar becomes $ncart->items +$myvar = 'items'; +$cart->$myvar = array("10" => 1); + </programlisting> + </informalexample> + + <para> + Within a class definition, you do not know under which name the object will + be accessible in your program: At the time the Cart class was + written, it was unknown that the object will be named $cart or + $another_cart later. Thus, you cannot write $cart-&gt;items within + the Cart class itself. Instead, in order to be able to access it's own + functions and variables from within a class, one can use the + pseudo-variable $this which can be read as 'my own' or + 'current object'. Thus, '$this->items[$artnr] += $num' can + be read as 'add $num to the $artnr counter of my own items + array' or 'add $num to the $artnr counter of the items array + within the current object'. + </para> + </sect1> + + <sect1 id="keyword.extends"> + <title><literal>extends</literal></title> + + <para> + Often you need classes with similar variables and functions + to another existing class. In fact, it is good practice to + define a generic class which can be used in all your + projects and adapt this class for the needs of each of your + specific projects. To facilitate this, Classes can be + extensions of other classes. The extended or derived class + has all variables and functions of the base class (this is + called 'inheritance' despite the fact that nobody died) and what + you add in the extended definition. It is not possible to + substract from a class, that is, to undefine any existing + functions or variables. An extended class is always dependent + on a single base class, that is, multiple inheritance is + not supported. Classes are extended using the keyword 'extends'. + </para> + + <informalexample> + <programlisting role="php"> class Named_Cart extends Cart { var $owner; @@ -107,7 +200,7 @@ <para> この例は、Cart の全ての変数及び関数に加えて変数 $owner と - 関数 $set_owner を保持するクラス Named_Cart を定義しています。 + 関数 set_owner() を保持するクラス Named_Cart を定義しています。 この定義により、名前付きの籠を通常の手段で作成し、籠の保有者を 設定したり得たりすることができます。 名前付きの籠で元の籠クラスの関数を使うことも可能です。 @@ -122,35 +215,31 @@ </programlisting> </informalexample> - <para> - クラスにおける関数の中では、変数 $this はそのオブジェクト自身を意 - 味します。オブジェクトの中では、何らかのクラス変数や関数にアクセス - したい場合に $this->something を使う必要があります。オブジェクトの - 内部または外部の場合、そのオブジェクトのプロパティにアクセスする際 - に $ は不要です。 - </para> - - <informalexample> - <programlisting role="php"> -$ncart->owner = "chris"; // $ は不要 + </sect1> -$ncart->$owner = "chris"; -// $ncart->$owner = $ncart->"" なのでこれは誤り + <sect1 id="language.oop.constructor"> + <title><literal>コンストラクタ</literal></title> -$myvar = 'owner'; -$ncart->$myvar = "chris"; -// $ncart->$myvar = $ncart->ownerなのでこれは有効 - </programlisting> - </informalexample> + <caution> + <simpara> + In PHP 3 and PHP 4 constructors behave differently. The PHP 4 + semantics are strongly preferred. + </simpara> + </caution> <para> - コンストラクタは、クラスの新しいインスタンスを作成する際に - 自動的にコールされるクラス関数です。 - 関数は、クラスと同じ名前を有する際にコンストラクタとなります。 + コンストラクタは、<literal>new</literal>によりクラスの新しいインス + タンスを作成する際に自動的にコールされるクラス関数です。 + PHP 3では、ある関数が、クラス名と同じ名前を有している場合にコンス + トラクタになりました。PHP 4では、ある関数が、そのコンストラクタが + 定義されているクラスと同じ名前を有している場合にコンストラクタにな + ります。これらの違いは僅かですが、重要な違いがあります。(以下、参 + 照) </para> - + <informalexample> <programlisting role="php"> +// Works in PHP 3 and PHP 4. class Auto_Cart extends Cart { function Auto_Cart () { $this->add_item ("10", 1); @@ -162,13 +251,16 @@ <para> この例は、Cart にコンストラクタを加えたクラス Auto_Cart を定義しています。 このコンストラクタは、"new" により新しい Auto_Cart が作成される度に - 籠に 10 番の物を一つ保持するように初期化します。 - コンストラクタは、オプションとして引数をとります。 - これにより、コンストラクタは非常に便利なものとなります。 + 籠に10番の物を一つ保持するように初期化します。コンストラクタは、オ + プションとして引数をとります。これにより、コンストラクタは非常に便 + 利なものとなります。To be able to still use the class + without parameters, all parameters to constructors should be + made optional by providing default values. </para> <informalexample> <programlisting role="php"> +// Works in PHP 3 and PHP 4. class Constructor_Cart extends Cart { function Constructor_Cart ($item = "10", $num = 1) { $this->add_item ($item, $num); @@ -184,18 +276,378 @@ $different_cart = new Constructor_Cart ("20", 17); </programlisting> </informalexample> - + <caution> <simpara> - 派生クラスの場合、派生クラスのコンストラクタがコールされた時にも - 親クラスのコンストラクタが自動的にコールされるということはありま - せん。 + In PHP 3, derived classes and constructors have a number of + limitations. The following examples should be read carefully + to understand these limitations. + </simpara> + </caution> + + <informalexample> + <programlisting role="php"> +class A { + function A() { + echo "I am the constructor of A.&lt;br>\n"; + } +} + +class B extends A { + function C() { + "I am a regular function.&lt;br>\n"; + } +} + +// no constructor is being called in PHP 3. +$b = new B; + </programlisting> + </informalexample> + + <para> + In PHP 3, no constructor is being called in the above example. + The rule in PHP 3 is: 'A constructor is a function of the same + name as the class.'. The name of the class is B, and there is + no function called B() in class B. Nothing happens. + </para> + + <para> + This is fixed in PHP 4 by introducing another rule: If a class + has no constructor, the constructor of the base class is being + called, if it exists. The above example would have printed + 'I am the constructor of A.&lt;br>' in PHP 4. + </para> + + <informalexample> + <programlisting role="php"> +class A { + function A() { + echo "I am the constructor of A.&lt;br>\n"; + } + + function B() { + echo "I am a regular function named B in class A.&lt;br>\n"; + echo "I am not a constructor in A.&lt;br>\n"; + } +} + +class B extends A { + function C() { + echo "I am a regular function.&lt;br>\n"; + } +} + +// This will call B() as a constructor. +$b = new B; + </programlisting> + </informalexample> + + <para> + In PHP 3, the function B() in class A will suddenly become a + constructor in class B, although it was never intended to be. + The rule in PHP 3 is: 'A constructor is a function of the same + name as the class.'. PHP 3 does not care if the function is + being defined in class B, or if it has been inherited. + </para> + + <para> + This is fixed in PHP 4 by modifying the rule to: 'A constructor + is a function of the same name as the class it is being defined + in.'. Thus in PHP 4, the class B would have no constructor function + of its own and the constructor of the base class would have been + called, printing 'I am the constructor of A.&lt;br>'. + </para> + + <caution> + <simpara> + Neither PHP 3 nor PHP 4 call constructors of the base class + automatically from a constructor of a derived class. It is + your responsibility to propagate the call to constructors + upstream where appropriate. </simpara> </caution> + + <note> + <simpara> + There are no destructors in PHP 3 or PHP 4. You may use + <function>register_shutdown_function</function> instead + to simulate most effects of destructors. + </simpara> + </note> + + <para> + Destructors are functions that are called automatically + when a variable is destroyed, either with <function>unset</function> + or by simply going out of scope. There are no destructors + in PHP. + </para> </sect1> - - <sect1 id="language.oop.newref"> - <title>コンストラクタの中での参照</title> + + <sect1 id="keyword.paamayim_nekudotayim"><!-- :-) --> + <title><literal>::</literal></title> + + <caution> + <simpara> + The following is valid for PHP 4 only. + </simpara> + </caution> + + <para> + Sometimes it is useful to refer to functions and variables + in base classes or to refer to functions in classes that + have not yet any instances. The :: operator is being used + for this. + </para> + + <informalexample> + <programlisting role="php"> +class A { + function example() { + echo "I am the original function A::example().&lt;br>\n"; + } +} + +class B extends A { + function example() { + echo "I am the redefined function B::example().&lt;br>\n"; + A::example(); + } +} + +// there is no object of class A. +// this will print +// I am the original function A::example().&lt;br> +A::example(); + +// create an object of class B. +$b = new B; + +// this will print +// I am the redefined function B::example().&lt;br> +// I am the original function A::example().&lt;br> +$b->example(); + </programlisting> + </informalexample> + + <para> + The above example calls the function example() in + class A, but there is no object of class A, so that + we cannot write $a->example() or similar. Instead we + call example() as a 'class function', that is, as a + function of the class itself, not any object of that + class. + </para> + + <para> + There are class functions, but there are no class variables. + In fact, there is no object at all at the time of the call. + Thus, a class function may not use any object variables (but + it can use local and global variables), and it may no use + $this at all. + </para> + + <para> + In the above example, class B redefines the function example(). + The original definition in class A is shadowed + and no longer available, unless you are refering specifically + to the implementation of example() in class A using the + ::-operator. Write A::example() to do this (in fact, you + should be writing parent::example(), as shown in the next + section). + </para> + + <para> + In this context, there is a current object and it may + have object variables. Thus, when used from WITHIN an + object function, you may use $this and object variables. + </para> + + </sect1> + + <sect1 id="keyword.parent"> + <title><literal>親クラス</literal></title> + + <para> + You may find yourself writing code that refers to + variables and functions in base classes. This is + particularly true if your derived class is a refinement + or specialisation of code in your base class. + </para> + + <para> + Instead of using the literal name of the base class in your + code, you should be using the special name + <literal>parent</literal>, which refers to the name of your + base class as given in the <literal>extends</literal> + declation of your class. By doing this, you avoid using the + name of your base class in more than one place. Should + your inheritance tree change during implementation, the + change is easily made by simply changing the + <literal>extends</literal> declaration of your class. + </para> + + <informalexample> + <programlisting role="php"> +class A { + function example() { + echo "I am A::example() and provide basic functionality.&lt;br>\n"; + } +} + +class B extends A { + function example() { + echo "I am B::example and provide additional functionality().&lt;br>\n"; + parent::example(); + } +} + +$b = new B; + +// This will call B::example(), which will in turn call A::example(). +$b->example(); + </programlisting> + </informalexample> + </sect1> + + <sect1 id="language.oop.serialization"> + <title>Serializing objects - objects in sessions</title> + + <note> + <simpara> + In PHP 3, objects will lose their class association + throughout the process of serialization and unserialization. + The resulting variable is of type object, but has no class + and no methods, thus it is pretty useless (it has become + just like an array with a funny syntax). + </simpara> + </note> + + <caution> + <simpara> + The following information is valid for PHP 4 only. + </simpara> + </caution> + + <para> + <function>serialize</function> returns a string containing a + byte-stream representation of any value that can be stored in + PHP. <function>unserialize</function> can use this string to + recreate the original variable values. Using serialize to + save an object will save all variables in an object. The + functions in an object will not be saved, only the name of + the class. + </para> + + <para> + In order to be able to <function>unserialize</function> an + object, the class of that object needs to be defined. That + is, if you have an object $a of class A on page1.php and + serialize this, you'll get a string that refers to class A + and contains all values of variabled contained in $a. If + you want to be able to unserialize this on page2.php, + recreating $a of class A, the definition of class A must + be present in page2.php. This can be done for example + by storing the class defintion of class A in an include + file and including this file in both page1.php and page2.php. + </para> + + <informalexample> + <programlisting role="php"> +classa.inc: + class A { + var $one = 1; + + function show_one() { + echo $this->one; + } + } + +page1.php: + include("classa.inc"); + + $a = new A; + $s = serialize($a); + // store $s somewhere where page2.php can find it. + $fp = fopen("store", "w"); + echo $s; + fclose($fp); + +page2.php: + // this is needed for the unserialize to work properly. + include("classa.inc"); + + $s = implode("", @file("store")); + unserialize($s); + + // now use the function show_one of the $a object. + $a->show_one(); + </programlisting> + </informalexample> + + <para> + If you are using sessions and use <function>session_register</function> + to register objects, these objects are serialized automatically + at the end of each PHP page, and are unserialized automatically on + each of the following pages. This basically means that these objects + can show up on any of your pages once they become part of your + session. + </para> + + <para> + It is strongly recommended that you include the class + definitions of all such registered objects on all of your + pages, even if you do not actually use these classes on all + of your pages. If you don't and an object is being + unserialized without its class definition being present, it + will lose its class association and become an object of class + <literal>stdClass</literal> without any functions available + at all, that is, it will become quite useless. + </para> + + <para> + So if the in the example above $a became part of a session by + running <literal>session_register("a")</literal>, you should + include the file <literal>classa.inc</literal> on all of your + pages, not only page1.php and page2.php. + </para> + </sect1> + + <sect1 id="language.oop.magic-functions"> + <title>The magic functions <literal>__sleep</literal> and <literal>__wakeup</literal></title> + + <para> + <function>serialize</function> checks if your class has a function with + the magic name <literal>__sleep</literal>. If so, that function is + being run prior to any serialization. It can clean up the object + and is supposed to return an array with the names of all variables + of that object that should be serialized. + </para> + + <para> + The intended use of <literal>__sleep</literal> is to close any + database connections that object may have, committing pending + data or perform similar cleanup tasks. Also, the function is + useful if you have very large objects which need not be + saved completely. + </para> + + <para> + Conversely, <function>unserialize</function> checks for the + presence of a function with the magic name + <literal>__wakeup</literal>. If present, this function can + reconstruct any ressources that object may have. + </para> + + <para> + The intended use of <literal>__wakeup</literal> is to + reestablish any database connections that may have been lost + during serialization and perform other reinitialization + tasks. + </para> + </sect1> + + <sect1 id="language.oop.newref"> + <title>コンストラクタの内部での参照</title> <para> コンストラクタの中で参照を作成すると結果が混乱する可能性があります。 本節ではチュートリアル形式で説明しますが、この問題を避けるために役 @@ -219,14 +671,14 @@ echo "&lt;br&gt;",$this->Name; } - function setName($name) { - $this->Name = $name; + function setName($name) { + $this->Name = $name; } } - </programlisting> - </informalexample> - </para> - + </programlisting> + </informalexample> + </para> + <para> コピー演算子 <literal>=</literal> により作成された <varname>$bar1</varname> と 参照演算子 <literal>=&amp;</literal> @@ -276,7 +728,7 @@ </note> 上記の記述が正しいことを示すために以下のコードを見てみましょう。 - <informalexample> + <informalexample> <programlisting role="php"> // ここで、name を変更してみます。どうなるでしょうか? // $bar と $globalref[0] の両方共名前が変わると予想するかもしれません... @@ -298,22 +750,23 @@ $globalref[1]->echoName(); /* 出力: -set from outside set from outside */ + set from outside + set from outside */ - </programlisting> + </programlisting> </informalexample> </para> <para> - 別の最後の例について考えてみて下さい。 - + 最後に別の例について考えてみて下さい。 + <informalexample> <programlisting role="php"> - + class a { function a($i) { - $this->value = $i; - // ここで参照を使う必要がない理由を考えてみて下さい - $this->b = new b($this); + $this->value = $i; + // ここで参照を使う必要がない理由を考えてみて下さい + $this->b = new b($this); } function createRef() { @@ -366,7 +819,7 @@ </informalexample> </para> </sect1> - + </chapter> <!-- Keep this comment at the end of the file Index: phpdoc/ja/pear/standards.xml diff -u phpdoc/ja/pear/standards.xml:1.4 phpdoc/ja/pear/standards.xml:1.5 --- phpdoc/ja/pear/standards.xml:1.4 Fri Apr 13 07:03:33 2001 +++ phpdoc/ja/pear/standards.xml Sun May 20 00:43:02 2001 @@ -1,6 +1,12 @@ <chapter id="pear.standards"> <title>PEAR コーディング標準</title> - + <note> + <simpara> + PEARコーディング標準(PEAR Coding Standards)は、PHPと共に配布される + か、PEARのインストールツールによりダウンロード可能であるかによらず、 + PEARにとりこまれるコードに適用します。 + </simpara> + </note> <sect1 id="pear.standards.indenting"> <title>インデント</title> <para> @@ -14,7 +20,10 @@ (setq tab-width 4 c-basic-offset 4 c-hanging-comment-ender-p nil - indent-tabs-mode nil)) + indent-tabs-mode + (not + (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name)) + (string-match "\.php$" (buffer-file-name)))))) </programlisting> </para> <para>
« previous php.doc (#969335443) next »