com doc/zh: sync to en: Added informaltable ids as needed by the docs at mysql.com: reference/mysql/changelog.xml
reference/mysql/functions/mysql-connect.xml reference/mysql/functions/mysql-db-name.xml reference/mysql/functions/mysql-list-tables.xml
reference/mysql/functions/mysql-pconnect.xml reference/mysql/functions/mysql-tablename.xml
| From: | Bole Chen | Date: | Mon, 08 Feb 2021 09:42:47 +0000 |
| Subject: | com doc/zh: sync to en: Added informaltable ids as needed by the docs at mysql.com: reference/mysql/changelog.xml reference/mysql/functions/mysql-connect.xml reference/mysql/functions/mysql-db-name.xml reference/mysql/functions/mysql-list-tables.xml reference/mysql/functions/mysql-pconnect.xml reference/mysql/functions/mysql-tablename.xml |
||
| Groups: | php.doc.zh | ||
| Request: | Send a blank email to doc-zh+get-5972@lists.php.net to get a copy of this message | ||
Commit: 791ce1a232edbde0c68237bc162519927d32a7ee
Author: Bole Chen <avenger@php.net> Mon, 8 Feb 2021 17:42:47 +0800
Parents: e118150f97aacacf30dce7a9775ce282fbcabf78
Branches: master
Link: http://git.php.net/?p=doc/zh.git;a=commitdiff;h=791ce1a232edbde0c68237bc162519927d32a7ee
Log:
sync to en: Added informaltable ids as needed by the docs at mysql.com
Changed paths:
M reference/mysql/changelog.xml
M reference/mysql/functions/mysql-connect.xml
M reference/mysql/functions/mysql-db-name.xml
M reference/mysql/functions/mysql-list-tables.xml
M reference/mysql/functions/mysql-pconnect.xml
M reference/mysql/functions/mysql-tablename.xml
diff --git a/reference/mysql/changelog.xml b/reference/mysql/changelog.xml index 5a66b30a..09c1bdb6 100644 --- a/reference/mysql/changelog.xml +++ b/reference/mysql/changelog.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 27e54b061f246ebc507cb23fe1837f38f0dcce7e Maintainer: daijie Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: daijie Status: ready --> <!-- Reviewed: no --> <appendix xmlns="http://docbook.org/ns/docbook" xml:id="changelog.mysql" xmlns:xlink="http://www.w3.org/1999/xlink"> @@ -13,14 +13,14 @@ ext/mysql 扩展相关的更新日志。 </para> </simplesect> - + <simplesect xml:id="changelog.mysql.global"> <title>全局 ext/mysql 的变更</title> <para> 以下列表是整个 ext/mysql 扩展的变动更新。 </para> <para> - <informaltable> + <informaltable xml:id="changelog.mysql.global.table"> <tgroup cols="2"> <thead> <row> @@ -33,7 +33,7 @@ <entry>7.0.0</entry> <entry> <para> - 此扩展从 PHP 中移除. 参见 + 此扩展已从 PHP 中移除。详见 <xref linkend="mysqlinfo.api.choosing"/>. </para> </entry> @@ -42,9 +42,9 @@ <entry>5.5.0</entry> <entry> <para> - 此扩展已经不建议使用。通过 <function>mysql_connect</function>、 - <function>mysql_pconnect</function> 或任何由 <literal>mysql_*</literal> 函数实现的 MySQL 数据库连接 - 将产生 <constant>E_DEPRECATED</constant> 错误。 + 此扩展已经不建议使用。通过 <function>mysql_connect</function>、<function>mysql_pconnect</function> + 或任何由 <literal>mysql_*</literal> 函数实现的 MySQL 数据库连接将产生 + <constant>E_DEPRECATED</constant> 错误。 </para> </entry> </row> @@ -67,7 +67,7 @@ </informaltable> </para> </simplesect> - + <simplesect xml:id="changelog.mysql.functions"> <title>函数的变更项</title> <para> @@ -75,7 +75,7 @@ </para> <?phpdoc generate-changelog-for="ref.mysql book.mysql"?> </simplesect> - + </appendix> <!-- Keep this comment at the end of the file diff --git a/reference/mysql/functions/mysql-connect.xml b/reference/mysql/functions/mysql-connect.xml index 39f1b38d..b1257758 100644 --- a/reference/mysql/functions/mysql-connect.xml +++ b/reference/mysql/functions/mysql-connect.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 70642d85d00cb893efced8e6e1ddf1d31085dc3b Maintainer: HonestQiao Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: HonestQiao Status: ready --> <!-- Reviewed: no Maintainer: HonestQiao --> <refentry xml:id="function.mysql-connect" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mysql_connect</refname> <refpurpose>打开一个到 MySQL 服务器的连接</refpurpose> </refnamediv> - + <refsynopsisdiv> <warning> &mysql.alternative.note; @@ -21,12 +21,12 @@ <refsect1 role="description"> &reftitle.description; <methodsynopsis> - <type>resource</type><methodname>mysql_connect</methodname> - <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> + <type class="union"><type>resource</type><type>false</type></type><methodname>mysql_connect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter><initializer>ini_get("mysql.default_host")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter><initializer>ini_get("mysql.default_user")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter><initializer>ini_get("mysql.default_password")</initializer></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter><initializer>&false;</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> 打开或重复使用一个到 MySQL 服务器的连接。 @@ -56,8 +56,8 @@ <listitem> <para> 用户名。默认值由 <link - linkend="ini.mysql.default-user">mysql.default_user</link> 定义。 - 在 &sqlsafemode; 时,参数被忽略,总是使用服务器进程所有者的用户名。 + linkend="ini.mysql.default-user">mysql.default_user</link> 定义。 在 + &sqlsafemode; 时,参数被忽略,总是使用服务器进程所有者的用户名。 </para> </listitem> </varlistentry> @@ -66,7 +66,8 @@ <listitem> <para> 密码。默认值由<link - linkend="ini.mysql.default-password">mysql.default_password</link>定义。在 &sqlsafemode; 时,参数被忽略,总是使用空密码。 + linkend="ini.mysql.default-password">mysql.default_password</link>定义。在 + &sqlsafemode; 时,参数被忽略,总是使用空密码。 </para> </listitem> </varlistentry> @@ -88,7 +89,8 @@ <para> <parameter>client_flags</parameter> 参数可以是以下常量的组合:<constant>MYSQL_CLIENT_SSL</constant>,<constant>MYSQL_CLIENT_COMPRESS</constant>,<constant>MYSQL_CLIENT_IGNORE_SPACE</constant> - 或 <constant>MYSQL_CLIENT_INTERACTIVE</constant>。进一步信息见<xref linkend="mysql.client-flags" />。 + 或 <constant>MYSQL_CLIENT_INTERACTIVE</constant>。进一步信息见 + <xref linkend="mysql.client-flags" />。 </para> </listitem> </varlistentry> @@ -106,7 +108,7 @@ <refsect1 role="changelog"> &reftitle.changelog; <para> - <informaltable> + <informaltable xml:id="function.mysql-connect.changelog"> <tgroup cols="2"> <thead> <row> @@ -116,27 +118,9 @@ </thead> <tbody> <row> - <entry>4.3.0</entry> - <entry> - 添加 <parameter>client_flags</parameter> 参数。 - </entry> - </row> - <row> - <entry>4.2.0</entry> - <entry> - 添加 <parameter>new_link</parameter> 参数。 - </entry> - </row> - <row> - <entry>3.0.10</entry> + <entry>5.5.0</entry> <entry> - 对 <parameter>server</parameter> 添加 ":/path/to/socket" 支持。 - </entry> - </row> - <row> - <entry>3.0.0</entry> - <entry> - 对 <parameter>server</parameter> 添加 ":port" 支持。 + 此函数会生成一个 <constant>E_DEPRECATED</constant> 错误。 </entry> </row> </tbody> @@ -198,8 +182,8 @@ mysql_close($link); <?php // we connect to localhost and socket e.g. /tmp/mysql.sock -//variant 1: ommit localhost -$link = mysql_connect('/tmp/mysql', 'mysql_user', 'mysql_password'); +// variant 1: omit localhost +$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } @@ -224,15 +208,6 @@ mysql_close($link); <refsect1 role="notes"> &reftitle.notes; <note> - &mysql.alternative.note; - <para> - <simplelist> - <member><function>mysqli_connect</function></member> - <member><methodname>PDO::__construct</methodname></member> - </simplelist> - </para> - </note> - <note> <para> 只要将 server 指定为 "localhost" 或 "localhost:port",MySQL 客户端库会越过此值并尝试连接到本地套接字(Windows @@ -250,9 +225,11 @@ mysql_close($link); </note> <note> <para> - 可以在函数名前加上一个 - <link linkend="language.operators.errorcontrol">@</link> - 来抑制出错时的错误信息。 + Error "Can't create TCP/IP socket (10106)" usually means that the <link + linkend="ini.variables-order">variables_order</link> configure directive + doesn't contain character <literal>E</literal>. On Windows, if the + environment is not copied the <literal>SYSTEMROOT</literal> environment + variable won't be available and PHP will have problems loading Winsock. </para> </note> </refsect1> diff --git a/reference/mysql/functions/mysql-db-name.xml b/reference/mysql/functions/mysql-db-name.xml index 9f9009d8..7daef7b0 100644 --- a/reference/mysql/functions/mysql-db-name.xml +++ b/reference/mysql/functions/mysql-db-name.xml @@ -1,19 +1,29 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 70642d85d00cb893efced8e6e1ddf1d31085dc3b Maintainer: HonestQiao Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: HonestQiao Status: ready --> <!-- Reviewed: no Maintainer: HonestQiao --> <refentry xml:id="function.mysql-db-name" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mysql_db_name</refname> - <refpurpose>取得结果数据</refpurpose> + <refpurpose>取得 <function>mysql_list_dbs</function> 返回的结果数据</refpurpose> </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member>Query: <literal>SELECT DATABASE()</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>mysql_db_name</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>int</type><parameter>row</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>field</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>field</parameter><initializer>NULL</initializer></methodparam> </methodsynopsis> <para> 取得 <function>mysql_list_dbs</function> 调用所返回的数据库名。 @@ -51,7 +61,7 @@ </variablelist> </para> </refsect1> - + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> @@ -59,7 +69,32 @@ <function>mysql_error</function> 来判断错误的种类。 </para> </refsect1> - + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-db-name.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + <function>mysql_list_dbs</function> 函数已废弃,调用时会抛出 + <constant>E_DEPRECATED</constant> 级别的错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + <refsect1 role="examples"> &reftitle.examples; <para> @@ -85,25 +120,17 @@ while ($i < $cnt) { </example> </para> </refsect1> - + <refsect1 role="notes"> &reftitle.notes; <note> - &mysql.alternative.note; - <para> - <simplelist> - <member>Query: <literal>SELECT DATABASE()</literal></member> - </simplelist> - </para> - </note> - <note> <para> &info.deprecated.alias; <function>mysql_dbname</function> </para> </note> </refsect1> - + <refsect1 role="seealso"> &reftitle.seealso; <para> diff --git a/reference/mysql/functions/mysql-list-tables.xml b/reference/mysql/functions/mysql-list-tables.xml index 9a5c510f..bed26281 100644 --- a/reference/mysql/functions/mysql-list-tables.xml +++ b/reference/mysql/functions/mysql-list-tables.xml @@ -1,81 +1,147 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-list-tables" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_list_tables</refname> - <refpurpose>列出 MySQL 数据库中的表</refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>resource</type><methodname>mysql_list_tables</methodname> - <methodparam><type>string</type><parameter>database</parameter></methodparam> - <methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam> - </methodsynopsis> - <para> - <function>mysql_list_tables</function> - 接受一个数据库名并返回和 - <function>mysql_query</function> - 函数很相似的一个结果指针。用 - <function>mysql_tablename</function> - 函数来遍历此结果指针,或者任何使用结果表的函数,例如 - <function>mysql_fetch_array</function>。 - </para> - <para> - <parameter>database</parameter> - 参数是需要被取得其中的的表名的数据库名。如果失败 - <function>mysql_list_tables</function> 返回 &false;。 - </para> - <para> - 为向下兼容仍然可以使用本函数的别名 - <function>mysql_listtables</function>,但反对这样做。 - </para> - <para> - <note> - <simpara> - 该函数已经被删除了,请不要再使用该函数。您可以用命令 SHOW TABLES FROM DATABASE 来实现该函数的功能。 - </simpara> - </note> - </para> - <para> - <example> - <title><function>mysql_list_tables</function> 例子</title> - <programlisting role="php"> +<refentry xml:id="function.mysql-list-tables" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_list_tables</refname> + <refpurpose>列出 MySQL 数据库中的表</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note.4-3-0; + <simplelist role="alternatives"> + <member>SQL Query: <literal>SHOW TABLES FROM dbname</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type class="union"><type>resource</type><type>false</type></type><methodname>mysql_list_tables</methodname> + <methodparam><type>string</type><parameter>database</parameter></methodparam> + <methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam> + </methodsynopsis> + <para> + 列出 MySQL 数据库中的表。 + </para> + <para> + 此函数已废弃。推荐使用 + <function>mysql_query</function> 来执行 SQL <literal>SHOW TABLES + [FROM db_name] [LIKE 'pattern']</literal> 来实现同样的操作。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>database</parameter></term> + <listitem> + <para> + 数据库名称 + </para> + </listitem> + </varlistentry> + &mysql.linkid.description; + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 成功时返回结果指针 <type>resource</type> &return.falseforfailure;。 + </para> + <para> + 可以使用 <function>mysql_tablename</function> 函数来遍历该结果指针,或者使用任何针对表操作的函数,类似 + <function>mysql_fetch_array</function>。 + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-list-tables.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>4.3.7</entry> + <entry> + 此函数已废弃。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mysql_list_tables</function> 例子</title> + <programlisting role="php"> <![CDATA[ <?php - $dbname = 'mysql_dbname'; +$dbname = 'mysql_dbname'; - if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { - print 'Could not connect to mysql'; - exit; - } +if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { + echo 'Could not connect to mysql'; + exit; +} - $result = mysql_list_tables($dbname); +$sql = "SHOW TABLES FROM $dbname"; +$result = mysql_query($sql); - if (!$result) { - print "DB Error, could not list tables\n"; - print 'MySQL Error: ' . mysql_error(); - exit; - } +if (!$result) { + echo "DB Error, could not list tables\n"; + echo 'MySQL Error: ' . mysql_error(); + exit; +} - while ($row = mysql_fetch_row($result)) { - print "Table: $row[0]\n"; - } +while ($row = mysql_fetch_row($result)) { + echo "Table: {$row[0]}\n"; +} - mysql_free_result($result); +mysql_free_result($result); ?> ]]> - </programlisting> - </example> - </para> - <para> - 参见 <function>mysql_list_dbs</function> 和 - <function>mysql_tablename</function>。 - </para> - </refsect1> - </refentry> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + &info.deprecated.alias; + <function>mysql_listtables</function> + </para> + </note> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_list_dbs</function></member> + <member><function>mysql_tablename</function></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: diff --git a/reference/mysql/functions/mysql-pconnect.xml b/reference/mysql/functions/mysql-pconnect.xml index 4a946679..f593bd93 100644 --- a/reference/mysql/functions/mysql-pconnect.xml +++ b/reference/mysql/functions/mysql-pconnect.xml @@ -1,90 +1,170 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-pconnect" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_pconnect</refname> - <refpurpose> - 打开一个到 MySQL 服务器的持久连接 - </refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>resource</type><methodname>mysql_pconnect</methodname> - <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> - </methodsynopsis> - <para> - 如果成功则返回一个正的 MySQL 持久连接标识符,出错则返回 &false;。 - </para> - <para> - <function>mysql_pconnect</function> - 建立一个到 MySQL - 服务器的连接。如果没有提供可选参数,则使用如下默认值:<parameter>server</parameter> = - 'localhost:3306',<parameter>username</parameter> = - 服务器进程所有者的用户名,<parameter>password</parameter> = - 空密码。<parameter>client_flags</parameter> - 参数可以是以下常量的组合:MYSQL_CLIENT_COMPRESS,MYSQL_CLIENT_IGNORE_SPACE - 或者 MYSQL_CLIENT_INTERACTIVE。 - </para> - <para> - <parameter>server</parameter> - 参数也可以包括端口号,例如 - "hostname:port",或者是本机套接字的的路径,例如 - ":/path/to/socket"。 - <note> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> +<refentry xml:id="function.mysql-pconnect" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_pconnect</refname> + <refpurpose>打开一个到 MySQL 服务器的持久连接</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member><function>mysqli_connect</function> with <literal>p:</literal> host prefix</member> + <member><methodname>PDO::__construct</methodname> with <constant>PDO::ATTR_PERSISTENT</constant> as a driver option</member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>resource</type><methodname>mysql_pconnect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter><initializer>ini_get("mysql.default_host")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter><initializer>ini_get("mysql.default_user")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter><initializer>ini_get("mysql.default_password")</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter><initializer>0</initializer></methodparam> + </methodsynopsis> + <!-- Undocumented confusing syntax: + <methodsynopsis> + <type>resource</type><methodname>mysql_pconnect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> + </methodsynopsis> + --> + <para> + 打开一个到 MySQL 服务器的持久连接。 + </para> + <!-- TODO: Integrate this information more nicely with features.persistent --> + <para> + <function>mysql_pconnect</function> 和 + <function>mysql_connect</function> 非常相似,但有两个主要区别。 + </para> + <para> + 首先,当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。 + </para> + <para> + 其次,当脚本执行完毕后到 SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(<function>mysql_close</function> + 不会关闭由 <function>mysql_pconnect</function> 建立的连接)。 + </para> + <para> + 此种连接称为“持久的”。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>server</parameter></term> + <listitem> + <para> + MySQL 服务器地址,参数也可以包括端口号,例如 + “hostname:port“ 或者是本机套接字的的路径,例如 “:/path/to/socket“ + </para> + <para> + 如果 PHP 配置文件中 <link linkend="ini.mysql.default-host"> + mysql.default_host</link> 的值未设置(默认情况下),则默认值为 'localhost:3306' + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>username</parameter></term> + <listitem> + <para> + 数据库连接使用的用户名。默认为当前服务器进程的用户。 + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>password</parameter></term> + <listitem> <para> - 对 ":port" 的支持是 3.0B4 版添加的。 + 数据库连接使用的密码。默认为空密码。 </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>client_flags</parameter></term> + <listitem> <para> - 对 ":/path/to/socket" 的支持是 3.0.10 版添加的。 + 参数 <parameter>client_flags</parameter> 可以为以下常量: + 128 (enable <literal>LOAD DATA LOCAL</literal> handling), + <constant>MYSQL_CLIENT_SSL</constant>, + <constant>MYSQL_CLIENT_COMPRESS</constant>, + <constant>MYSQL_CLIENT_IGNORE_SPACE</constant> 或 + <constant>MYSQL_CLIENT_INTERACTIVE</constant>。 </para> - </note> - </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 如果成功则返回一个正的 MySQL 持久连接标识符,出错则返回 &false;。 + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-pconnect.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + 函数会抛出一个 <constant>E_DEPRECATED</constant> 错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + 需要注意的是,此函数仅当在 PHP 模块化运行时才会生效。更多信息请参阅 + <link linkend="features.persistent-connections">持久数据库连接</link> 章节。 + </para> + </note> + <warning> + <para> + 使用持久连接可能需要对 Apache 和 MySQL 配置进行一些调整,以确保不超过 + MySQL 服务器允许的最大连接数。 + </para> + </warning> + </refsect1> - <!-- TODO move the story to features.persistent, and refer to that --> - <para> - <function>mysql_pconnect</function> - 和 - <function>mysql_connect</function> - 非常相似,但有两个主要区别。 - </para> - <para> - 首先,当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。 - </para> - <para> - 其次,当脚本执行完毕后到 - SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(<function>mysql_close</function> - 不会关闭由 - <function>mysql_pconnect</function> 建立的连接)。 - </para> - <para> - 可选参数 - <parameter>client_flags</parameter> - 自 PHP 4.3.0 版起可用。 - </para> - <para> - 此种连接称为“持久的”。 - </para> - <note> - <para> - 注意,此种连接仅能用于模块版本的 PHP。更多信息参见<link - linkend="features.persistent-connections">数据库持久连接</link>一节。 - </para> - </note> - <warning> - <para> - 使用持久连接需要调整一些 - Apache 和 MySQL - 的配置以使不会超出 MySQL 所允许的连接数目。 - </para> - </warning> - </refsect1> - </refentry> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_connect</function></member> + <member><link linkend="features.persistent-connections">Persistent + Database Connections</link></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: diff --git a/reference/mysql/functions/mysql-tablename.xml b/reference/mysql/functions/mysql-tablename.xml index a35f08dc..92d48ebd 100644 --- a/reference/mysql/functions/mysql-tablename.xml +++ b/reference/mysql/functions/mysql-tablename.xml @@ -1,51 +1,144 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-tablename" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_tablename</refname> - <refpurpose>取得表名</refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>string</type><methodname>mysql_tablename</methodname> - <methodparam><type>resource</type><parameter>result</parameter></methodparam> - <methodparam><type>int</type><parameter>i</parameter></methodparam> - </methodsynopsis> - <para> - <function>mysql_tablename</function> - 接受 - <function>mysql_list_tables</function> - 返回的结果指针以及一个整数索引作为参数并返回表名。可以用 - <function>mysql_num_rows</function> - 函数来判断结果指针中的表的数目。用 - <function>mysql_tablename</function> - 函数来遍历此结果指针,或者任何处理结果表的函数,例如 - <function>mysql_fetch_array</function>。 - <example> - <title><function>mysql_tablename</function> 例子</title> - <programlisting role="php"> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> +<refentry xml:id="function.mysql-tablename" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_tablename</refname> + <refpurpose>取得表名</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member>SQL Query: <literal>SHOW TABLES</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type class="union"><type>string</type><type>false</type></type><methodname>mysql_tablename</methodname> + <methodparam><type>resource</type><parameter>result</parameter></methodparam> + <methodparam><type>int</type><parameter>i</parameter></methodparam> + </methodsynopsis> + <para> + 从 <parameter>result</parameter> 中取得表名。 + </para> + <para> + 此函数已废弃,推荐使用 + <function>mysql_query</function> 函数来执行 SQL <literal>SHOW TABLES + [FROM db_name] [LIKE 'pattern']</literal> 替代。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>result</parameter></term> + <listitem> + <para> + 接受 <function>mysql_list_tables</function> 返回的结果指针以及一个整数索引作为参数并返回表名。 + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i</parameter></term> + <listitem> + <para> + The integer index (row/table number) + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 成功时返回表名&return.falseforfailure;。 + </para> + <para> + Use the <function>mysql_tablename</function> function to + traverse this result pointer, or any function for result tables, + such as <function>mysql_fetch_array</function>. + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-tablename.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + <function>mysql_tablename</function> 函数已废弃,调用时会抛出 + <constant>E_DEPRECATED</constant> 级别的错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mysql_tablename</function> example</title> + <programlisting role="php"> <![CDATA[ <?php - mysql_connect("localhost", "mysql_user", "mysql_password"); - $result = mysql_list_tables("mydb"); - - for ($i = 0; $i < mysql_num_rows($result); $i++) - printf ("Table: %s\n", mysql_tablename($result, $i)); +mysql_connect("localhost", "mysql_user", "mysql_password"); +$result = mysql_list_tables("mydb"); +$num_rows = mysql_num_rows($result); +for ($i = 0; $i < $num_rows; $i++) { + echo "Table: ", mysql_tablename($result, $i), "\n"; +} - mysql_free_result($result); +mysql_free_result($result); ?> ]]> - </programlisting> - </example> - </para> - <para> - 参见 <function>mysql_list_tables</function>。 - </para> - </refsect1> - </refentry> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + The <function>mysql_num_rows</function> function may be used to + determine the number of tables in the result pointer. + </para> + </note> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_list_tables</function></member> + <member><function>mysql_field_table</function></member> + <member><function>mysql_db_name</function></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables:
diff --git a/reference/mysql/changelog.xml b/reference/mysql/changelog.xml index 5a66b30a..09c1bdb6 100644 --- a/reference/mysql/changelog.xml +++ b/reference/mysql/changelog.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 27e54b061f246ebc507cb23fe1837f38f0dcce7e Maintainer: daijie Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: daijie Status: ready --> <!-- Reviewed: no --> <appendix xmlns="http://docbook.org/ns/docbook" xml:id="changelog.mysql" xmlns:xlink="http://www.w3.org/1999/xlink"> @@ -13,14 +13,14 @@ ext/mysql 扩展相关的更新日志。 </para> </simplesect> - + <simplesect xml:id="changelog.mysql.global"> <title>全局 ext/mysql 的变更</title> <para> 以下列表是整个 ext/mysql 扩展的变动更新。 </para> <para> - <informaltable> + <informaltable xml:id="changelog.mysql.global.table"> <tgroup cols="2"> <thead> <row> @@ -33,7 +33,7 @@ <entry>7.0.0</entry> <entry> <para> - 此扩展从 PHP 中移除. 参见 + 此扩展已从 PHP 中移除。详见 <xref linkend="mysqlinfo.api.choosing"/>. </para> </entry> @@ -42,9 +42,9 @@ <entry>5.5.0</entry> <entry> <para> - 此扩展已经不建议使用。通过 <function>mysql_connect</function>、 - <function>mysql_pconnect</function> 或任何由 <literal>mysql_*</literal> 函数实现的 MySQL 数据库连接 - 将产生 <constant>E_DEPRECATED</constant> 错误。 + 此扩展已经不建议使用。通过 <function>mysql_connect</function>、<function>mysql_pconnect</function> + 或任何由 <literal>mysql_*</literal> 函数实现的 MySQL 数据库连接将产生 + <constant>E_DEPRECATED</constant> 错误。 </para> </entry> </row> @@ -67,7 +67,7 @@ </informaltable> </para> </simplesect> - + <simplesect xml:id="changelog.mysql.functions"> <title>函数的变更项</title> <para> @@ -75,7 +75,7 @@ </para> <?phpdoc generate-changelog-for="ref.mysql book.mysql"?> </simplesect> - + </appendix> <!-- Keep this comment at the end of the file diff --git a/reference/mysql/functions/mysql-connect.xml b/reference/mysql/functions/mysql-connect.xml index 39f1b38d..b1257758 100644 --- a/reference/mysql/functions/mysql-connect.xml +++ b/reference/mysql/functions/mysql-connect.xml @@ -1,13 +1,13 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 70642d85d00cb893efced8e6e1ddf1d31085dc3b Maintainer: HonestQiao Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: HonestQiao Status: ready --> <!-- Reviewed: no Maintainer: HonestQiao --> <refentry xml:id="function.mysql-connect" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mysql_connect</refname> <refpurpose>打开一个到 MySQL 服务器的连接</refpurpose> </refnamediv> - + <refsynopsisdiv> <warning> &mysql.alternative.note; @@ -21,12 +21,12 @@ <refsect1 role="description"> &reftitle.description; <methodsynopsis> - <type>resource</type><methodname>mysql_connect</methodname> - <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> + <type class="union"><type>resource</type><type>false</type></type><methodname>mysql_connect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter><initializer>ini_get("mysql.default_host")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter><initializer>ini_get("mysql.default_user")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter><initializer>ini_get("mysql.default_password")</initializer></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter><initializer>&false;</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> 打开或重复使用一个到 MySQL 服务器的连接。 @@ -56,8 +56,8 @@ <listitem> <para> 用户名。默认值由 <link - linkend="ini.mysql.default-user">mysql.default_user</link> 定义。 - 在 &sqlsafemode; 时,参数被忽略,总是使用服务器进程所有者的用户名。 + linkend="ini.mysql.default-user">mysql.default_user</link> 定义。 在 + &sqlsafemode; 时,参数被忽略,总是使用服务器进程所有者的用户名。 </para> </listitem> </varlistentry> @@ -66,7 +66,8 @@ <listitem> <para> 密码。默认值由<link - linkend="ini.mysql.default-password">mysql.default_password</link>定义。在 &sqlsafemode; 时,参数被忽略,总是使用空密码。 + linkend="ini.mysql.default-password">mysql.default_password</link>定义。在 + &sqlsafemode; 时,参数被忽略,总是使用空密码。 </para> </listitem> </varlistentry> @@ -88,7 +89,8 @@ <para> <parameter>client_flags</parameter> 参数可以是以下常量的组合:<constant>MYSQL_CLIENT_SSL</constant>,<constant>MYSQL_CLIENT_COMPRESS</constant>,<constant>MYSQL_CLIENT_IGNORE_SPACE</constant> - 或 <constant>MYSQL_CLIENT_INTERACTIVE</constant>。进一步信息见<xref linkend="mysql.client-flags" />。 + 或 <constant>MYSQL_CLIENT_INTERACTIVE</constant>。进一步信息见 + <xref linkend="mysql.client-flags" />。 </para> </listitem> </varlistentry> @@ -106,7 +108,7 @@ <refsect1 role="changelog"> &reftitle.changelog; <para> - <informaltable> + <informaltable xml:id="function.mysql-connect.changelog"> <tgroup cols="2"> <thead> <row> @@ -116,27 +118,9 @@ </thead> <tbody> <row> - <entry>4.3.0</entry> - <entry> - 添加 <parameter>client_flags</parameter> 参数。 - </entry> - </row> - <row> - <entry>4.2.0</entry> - <entry> - 添加 <parameter>new_link</parameter> 参数。 - </entry> - </row> - <row> - <entry>3.0.10</entry> + <entry>5.5.0</entry> <entry> - 对 <parameter>server</parameter> 添加 ":/path/to/socket" 支持。 - </entry> - </row> - <row> - <entry>3.0.0</entry> - <entry> - 对 <parameter>server</parameter> 添加 ":port" 支持。 + 此函数会生成一个 <constant>E_DEPRECATED</constant> 错误。 </entry> </row> </tbody> @@ -198,8 +182,8 @@ mysql_close($link); <?php // we connect to localhost and socket e.g. /tmp/mysql.sock -//variant 1: ommit localhost -$link = mysql_connect('/tmp/mysql', 'mysql_user', 'mysql_password'); +// variant 1: omit localhost +$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password'); if (!$link) { die('Could not connect: ' . mysql_error()); } @@ -224,15 +208,6 @@ mysql_close($link); <refsect1 role="notes"> &reftitle.notes; <note> - &mysql.alternative.note; - <para> - <simplelist> - <member><function>mysqli_connect</function></member> - <member><methodname>PDO::__construct</methodname></member> - </simplelist> - </para> - </note> - <note> <para> 只要将 server 指定为 "localhost" 或 "localhost:port",MySQL 客户端库会越过此值并尝试连接到本地套接字(Windows @@ -250,9 +225,11 @@ mysql_close($link); </note> <note> <para> - 可以在函数名前加上一个 - <link linkend="language.operators.errorcontrol">@</link> - 来抑制出错时的错误信息。 + Error "Can't create TCP/IP socket (10106)" usually means that the <link + linkend="ini.variables-order">variables_order</link> configure directive + doesn't contain character <literal>E</literal>. On Windows, if the + environment is not copied the <literal>SYSTEMROOT</literal> environment + variable won't be available and PHP will have problems loading Winsock. </para> </note> </refsect1> diff --git a/reference/mysql/functions/mysql-db-name.xml b/reference/mysql/functions/mysql-db-name.xml index 9f9009d8..7daef7b0 100644 --- a/reference/mysql/functions/mysql-db-name.xml +++ b/reference/mysql/functions/mysql-db-name.xml @@ -1,19 +1,29 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 70642d85d00cb893efced8e6e1ddf1d31085dc3b Maintainer: HonestQiao Status: ready --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: HonestQiao Status: ready --> <!-- Reviewed: no Maintainer: HonestQiao --> <refentry xml:id="function.mysql-db-name" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>mysql_db_name</refname> - <refpurpose>取得结果数据</refpurpose> + <refpurpose>取得 <function>mysql_list_dbs</function> 返回的结果数据</refpurpose> </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member>Query: <literal>SELECT DATABASE()</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>mysql_db_name</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>int</type><parameter>row</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>field</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>field</parameter><initializer>NULL</initializer></methodparam> </methodsynopsis> <para> 取得 <function>mysql_list_dbs</function> 调用所返回的数据库名。 @@ -51,7 +61,7 @@ </variablelist> </para> </refsect1> - + <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> @@ -59,7 +69,32 @@ <function>mysql_error</function> 来判断错误的种类。 </para> </refsect1> - + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-db-name.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + <function>mysql_list_dbs</function> 函数已废弃,调用时会抛出 + <constant>E_DEPRECATED</constant> 级别的错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + <refsect1 role="examples"> &reftitle.examples; <para> @@ -85,25 +120,17 @@ while ($i < $cnt) { </example> </para> </refsect1> - + <refsect1 role="notes"> &reftitle.notes; <note> - &mysql.alternative.note; - <para> - <simplelist> - <member>Query: <literal>SELECT DATABASE()</literal></member> - </simplelist> - </para> - </note> - <note> <para> &info.deprecated.alias; <function>mysql_dbname</function> </para> </note> </refsect1> - + <refsect1 role="seealso"> &reftitle.seealso; <para> diff --git a/reference/mysql/functions/mysql-list-tables.xml b/reference/mysql/functions/mysql-list-tables.xml index 9a5c510f..bed26281 100644 --- a/reference/mysql/functions/mysql-list-tables.xml +++ b/reference/mysql/functions/mysql-list-tables.xml @@ -1,81 +1,147 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-list-tables" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_list_tables</refname> - <refpurpose>列出 MySQL 数据库中的表</refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>resource</type><methodname>mysql_list_tables</methodname> - <methodparam><type>string</type><parameter>database</parameter></methodparam> - <methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam> - </methodsynopsis> - <para> - <function>mysql_list_tables</function> - 接受一个数据库名并返回和 - <function>mysql_query</function> - 函数很相似的一个结果指针。用 - <function>mysql_tablename</function> - 函数来遍历此结果指针,或者任何使用结果表的函数,例如 - <function>mysql_fetch_array</function>。 - </para> - <para> - <parameter>database</parameter> - 参数是需要被取得其中的的表名的数据库名。如果失败 - <function>mysql_list_tables</function> 返回 &false;。 - </para> - <para> - 为向下兼容仍然可以使用本函数的别名 - <function>mysql_listtables</function>,但反对这样做。 - </para> - <para> - <note> - <simpara> - 该函数已经被删除了,请不要再使用该函数。您可以用命令 SHOW TABLES FROM DATABASE 来实现该函数的功能。 - </simpara> - </note> - </para> - <para> - <example> - <title><function>mysql_list_tables</function> 例子</title> - <programlisting role="php"> +<refentry xml:id="function.mysql-list-tables" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_list_tables</refname> + <refpurpose>列出 MySQL 数据库中的表</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note.4-3-0; + <simplelist role="alternatives"> + <member>SQL Query: <literal>SHOW TABLES FROM dbname</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type class="union"><type>resource</type><type>false</type></type><methodname>mysql_list_tables</methodname> + <methodparam><type>string</type><parameter>database</parameter></methodparam> + <methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam> + </methodsynopsis> + <para> + 列出 MySQL 数据库中的表。 + </para> + <para> + 此函数已废弃。推荐使用 + <function>mysql_query</function> 来执行 SQL <literal>SHOW TABLES + [FROM db_name] [LIKE 'pattern']</literal> 来实现同样的操作。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>database</parameter></term> + <listitem> + <para> + 数据库名称 + </para> + </listitem> + </varlistentry> + &mysql.linkid.description; + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 成功时返回结果指针 <type>resource</type> &return.falseforfailure;。 + </para> + <para> + 可以使用 <function>mysql_tablename</function> 函数来遍历该结果指针,或者使用任何针对表操作的函数,类似 + <function>mysql_fetch_array</function>。 + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-list-tables.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>4.3.7</entry> + <entry> + 此函数已废弃。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mysql_list_tables</function> 例子</title> + <programlisting role="php"> <![CDATA[ <?php - $dbname = 'mysql_dbname'; +$dbname = 'mysql_dbname'; - if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { - print 'Could not connect to mysql'; - exit; - } +if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { + echo 'Could not connect to mysql'; + exit; +} - $result = mysql_list_tables($dbname); +$sql = "SHOW TABLES FROM $dbname"; +$result = mysql_query($sql); - if (!$result) { - print "DB Error, could not list tables\n"; - print 'MySQL Error: ' . mysql_error(); - exit; - } +if (!$result) { + echo "DB Error, could not list tables\n"; + echo 'MySQL Error: ' . mysql_error(); + exit; +} - while ($row = mysql_fetch_row($result)) { - print "Table: $row[0]\n"; - } +while ($row = mysql_fetch_row($result)) { + echo "Table: {$row[0]}\n"; +} - mysql_free_result($result); +mysql_free_result($result); ?> ]]> - </programlisting> - </example> - </para> - <para> - 参见 <function>mysql_list_dbs</function> 和 - <function>mysql_tablename</function>。 - </para> - </refsect1> - </refentry> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + &info.deprecated.alias; + <function>mysql_listtables</function> + </para> + </note> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_list_dbs</function></member> + <member><function>mysql_tablename</function></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: diff --git a/reference/mysql/functions/mysql-pconnect.xml b/reference/mysql/functions/mysql-pconnect.xml index 4a946679..f593bd93 100644 --- a/reference/mysql/functions/mysql-pconnect.xml +++ b/reference/mysql/functions/mysql-pconnect.xml @@ -1,90 +1,170 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-pconnect" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_pconnect</refname> - <refpurpose> - 打开一个到 MySQL 服务器的持久连接 - </refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>resource</type><methodname>mysql_pconnect</methodname> - <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> - <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> - </methodsynopsis> - <para> - 如果成功则返回一个正的 MySQL 持久连接标识符,出错则返回 &false;。 - </para> - <para> - <function>mysql_pconnect</function> - 建立一个到 MySQL - 服务器的连接。如果没有提供可选参数,则使用如下默认值:<parameter>server</parameter> = - 'localhost:3306',<parameter>username</parameter> = - 服务器进程所有者的用户名,<parameter>password</parameter> = - 空密码。<parameter>client_flags</parameter> - 参数可以是以下常量的组合:MYSQL_CLIENT_COMPRESS,MYSQL_CLIENT_IGNORE_SPACE - 或者 MYSQL_CLIENT_INTERACTIVE。 - </para> - <para> - <parameter>server</parameter> - 参数也可以包括端口号,例如 - "hostname:port",或者是本机套接字的的路径,例如 - ":/path/to/socket"。 - <note> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> +<refentry xml:id="function.mysql-pconnect" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_pconnect</refname> + <refpurpose>打开一个到 MySQL 服务器的持久连接</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member><function>mysqli_connect</function> with <literal>p:</literal> host prefix</member> + <member><methodname>PDO::__construct</methodname> with <constant>PDO::ATTR_PERSISTENT</constant> as a driver option</member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>resource</type><methodname>mysql_pconnect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter><initializer>ini_get("mysql.default_host")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter><initializer>ini_get("mysql.default_user")</initializer></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter><initializer>ini_get("mysql.default_password")</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter><initializer>0</initializer></methodparam> + </methodsynopsis> + <!-- Undocumented confusing syntax: + <methodsynopsis> + <type>resource</type><methodname>mysql_pconnect</methodname> + <methodparam choice="opt"><type>string</type><parameter>server</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>username</parameter></methodparam> + <methodparam choice="opt"><type>string</type><parameter>password</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>new_link</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>client_flags</parameter></methodparam> + </methodsynopsis> + --> + <para> + 打开一个到 MySQL 服务器的持久连接。 + </para> + <!-- TODO: Integrate this information more nicely with features.persistent --> + <para> + <function>mysql_pconnect</function> 和 + <function>mysql_connect</function> 非常相似,但有两个主要区别。 + </para> + <para> + 首先,当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。 + </para> + <para> + 其次,当脚本执行完毕后到 SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(<function>mysql_close</function> + 不会关闭由 <function>mysql_pconnect</function> 建立的连接)。 + </para> + <para> + 此种连接称为“持久的”。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>server</parameter></term> + <listitem> + <para> + MySQL 服务器地址,参数也可以包括端口号,例如 + “hostname:port“ 或者是本机套接字的的路径,例如 “:/path/to/socket“ + </para> + <para> + 如果 PHP 配置文件中 <link linkend="ini.mysql.default-host"> + mysql.default_host</link> 的值未设置(默认情况下),则默认值为 'localhost:3306' + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>username</parameter></term> + <listitem> + <para> + 数据库连接使用的用户名。默认为当前服务器进程的用户。 + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>password</parameter></term> + <listitem> <para> - 对 ":port" 的支持是 3.0B4 版添加的。 + 数据库连接使用的密码。默认为空密码。 </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>client_flags</parameter></term> + <listitem> <para> - 对 ":/path/to/socket" 的支持是 3.0.10 版添加的。 + 参数 <parameter>client_flags</parameter> 可以为以下常量: + 128 (enable <literal>LOAD DATA LOCAL</literal> handling), + <constant>MYSQL_CLIENT_SSL</constant>, + <constant>MYSQL_CLIENT_COMPRESS</constant>, + <constant>MYSQL_CLIENT_IGNORE_SPACE</constant> 或 + <constant>MYSQL_CLIENT_INTERACTIVE</constant>。 </para> - </note> - </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 如果成功则返回一个正的 MySQL 持久连接标识符,出错则返回 &false;。 + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-pconnect.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + 函数会抛出一个 <constant>E_DEPRECATED</constant> 错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + 需要注意的是,此函数仅当在 PHP 模块化运行时才会生效。更多信息请参阅 + <link linkend="features.persistent-connections">持久数据库连接</link> 章节。 + </para> + </note> + <warning> + <para> + 使用持久连接可能需要对 Apache 和 MySQL 配置进行一些调整,以确保不超过 + MySQL 服务器允许的最大连接数。 + </para> + </warning> + </refsect1> - <!-- TODO move the story to features.persistent, and refer to that --> - <para> - <function>mysql_pconnect</function> - 和 - <function>mysql_connect</function> - 非常相似,但有两个主要区别。 - </para> - <para> - 首先,当连接的时候本函数将先尝试寻找一个在同一个主机上用同样的用户名和密码已经打开的(持久)连接,如果找到,则返回此连接标识而不打开新连接。 - </para> - <para> - 其次,当脚本执行完毕后到 - SQL 服务器的连接不会被关闭,此连接将保持打开以备以后使用(<function>mysql_close</function> - 不会关闭由 - <function>mysql_pconnect</function> 建立的连接)。 - </para> - <para> - 可选参数 - <parameter>client_flags</parameter> - 自 PHP 4.3.0 版起可用。 - </para> - <para> - 此种连接称为“持久的”。 - </para> - <note> - <para> - 注意,此种连接仅能用于模块版本的 PHP。更多信息参见<link - linkend="features.persistent-connections">数据库持久连接</link>一节。 - </para> - </note> - <warning> - <para> - 使用持久连接需要调整一些 - Apache 和 MySQL - 的配置以使不会超出 MySQL 所允许的连接数目。 - </para> - </warning> - </refsect1> - </refentry> + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_connect</function></member> + <member><link linkend="features.persistent-connections">Persistent + Database Connections</link></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: diff --git a/reference/mysql/functions/mysql-tablename.xml b/reference/mysql/functions/mysql-tablename.xml index a35f08dc..92d48ebd 100644 --- a/reference/mysql/functions/mysql-tablename.xml +++ b/reference/mysql/functions/mysql-tablename.xml @@ -1,51 +1,144 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> <!-- $Author$ --> -<!-- EN-Revision: n/a Maintainer: dallas Status: ready --> - <refentry xml:id="function.mysql-tablename" xmlns="http://docbook.org/ns/docbook"> - <refnamediv> - <refname>mysql_tablename</refname> - <refpurpose>取得表名</refpurpose> - </refnamediv> - <refsect1> - <title>说明</title> - <methodsynopsis> - <type>string</type><methodname>mysql_tablename</methodname> - <methodparam><type>resource</type><parameter>result</parameter></methodparam> - <methodparam><type>int</type><parameter>i</parameter></methodparam> - </methodsynopsis> - <para> - <function>mysql_tablename</function> - 接受 - <function>mysql_list_tables</function> - 返回的结果指针以及一个整数索引作为参数并返回表名。可以用 - <function>mysql_num_rows</function> - 函数来判断结果指针中的表的数目。用 - <function>mysql_tablename</function> - 函数来遍历此结果指针,或者任何处理结果表的函数,例如 - <function>mysql_fetch_array</function>。 - <example> - <title><function>mysql_tablename</function> 例子</title> - <programlisting role="php"> +<!-- EN-Revision: 4206843127f9a72a283b63ac82c0155a598506b1 Maintainer: avenger Status: ready --> +<refentry xml:id="function.mysql-tablename" xmlns="http://docbook.org/ns/docbook"> + <refnamediv> + <refname>mysql_tablename</refname> + <refpurpose>取得表名</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <warning> + &mysql.alternative.note; + <simplelist role="alternatives"> + <member>SQL Query: <literal>SHOW TABLES</literal></member> + </simplelist> + </warning> + </refsynopsisdiv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type class="union"><type>string</type><type>false</type></type><methodname>mysql_tablename</methodname> + <methodparam><type>resource</type><parameter>result</parameter></methodparam> + <methodparam><type>int</type><parameter>i</parameter></methodparam> + </methodsynopsis> + <para> + 从 <parameter>result</parameter> 中取得表名。 + </para> + <para> + 此函数已废弃,推荐使用 + <function>mysql_query</function> 函数来执行 SQL <literal>SHOW TABLES + [FROM db_name] [LIKE 'pattern']</literal> 替代。 + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>result</parameter></term> + <listitem> + <para> + 接受 <function>mysql_list_tables</function> 返回的结果指针以及一个整数索引作为参数并返回表名。 + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>i</parameter></term> + <listitem> + <para> + The integer index (row/table number) + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + 成功时返回表名&return.falseforfailure;。 + </para> + <para> + Use the <function>mysql_tablename</function> function to + traverse this result pointer, or any function for result tables, + such as <function>mysql_fetch_array</function>. + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable xml:id="function.mysql-tablename.changelog"> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.5.0</entry> + <entry> + <function>mysql_tablename</function> 函数已废弃,调用时会抛出 + <constant>E_DEPRECATED</constant> 级别的错误。 + </entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>mysql_tablename</function> example</title> + <programlisting role="php"> <![CDATA[ <?php - mysql_connect("localhost", "mysql_user", "mysql_password"); - $result = mysql_list_tables("mydb"); - - for ($i = 0; $i < mysql_num_rows($result); $i++) - printf ("Table: %s\n", mysql_tablename($result, $i)); +mysql_connect("localhost", "mysql_user", "mysql_password"); +$result = mysql_list_tables("mydb"); +$num_rows = mysql_num_rows($result); +for ($i = 0; $i < $num_rows; $i++) { + echo "Table: ", mysql_tablename($result, $i), "\n"; +} - mysql_free_result($result); +mysql_free_result($result); ?> ]]> - </programlisting> - </example> - </para> - <para> - 参见 <function>mysql_list_tables</function>。 - </para> - </refsect1> - </refentry> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + The <function>mysql_num_rows</function> function may be used to + determine the number of tables in the result pointer. + </para> + </note> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>mysql_list_tables</function></member> + <member><function>mysql_field_table</function></member> + <member><function>mysql_db_name</function></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: