cvs: phpdoc-zh /reference/mysql/functions mysql-insert-id.xml mysql-list-dbs.xml mysql-list-fields.xml mysql-list-processes.xml mysql-list-tables.xml

From: Date: Sat, 01 Mar 2003 12:18:32 +0000
Subject: cvs: phpdoc-zh /reference/mysql/functions mysql-insert-id.xml mysql-list-dbs.xml mysql-list-fields.xml mysql-list-processes.xml mysql-list-tables.xml
Groups: php.doc.zh 
Request: Send a blank email to doc-zh+get-1153@lists.php.net to get a copy of this message
dallas Sat Mar 1 07:18:32 2003 EDT Added files: /phpdoc-zh/reference/mysql/functions mysql-insert-id.xml mysql-list-dbs.xml mysql-list-fields.xml mysql-list-processes.xml mysql-list-tables.xml Log: Completed.

Index: phpdoc-zh/reference/mysql/functions/mysql-insert-id.xml +++ phpdoc-zh/reference/mysql/functions/mysql-insert-id.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.6 Maintainer: dallas Status: ready --> <refentry id="function.mysql-insert-id"> <refnamediv> <refname>mysql_insert_id</refname> <refpurpose> È¡µÃÉÏÒ»²½ INSERT ²Ù×÷²úÉúµÄ ID </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>int</type><methodname>mysql_insert_id</methodname> <methodparam choice="opt"><type>resource</type><parameter> link_identifier </parameter></methodparam> </methodsynopsis> <para> <function>mysql_insert_id</function> ·µ»Ø¸ø¶¨µÄ <parameter>link_identifier</parameter> ÖÐÉÏÒ»²½ INSERT ²éѯÖвúÉúµÄ AUTO_INCREMENT µÄ ID ºÅ¡£Èç¹ûûÓÐÖ¸¶¨ <parameter>link_identifier</parameter>£¬ÔòʹÓÃÉÏÒ»¸ö´ò¿ªµÄÁ¬½Ó¡£ </para> <para> Èç¹ûÉÏÒ»²éѯûÓвúÉú AUTO_INCREMENT µÄÖµ£¬Ôò <function>mysql_insert_id</function> ·µ»Ø 0¡£Èç¹ûÐèÒª±£´æ¸ÃÖµÒÔºóʹÓã¬ÒªÈ·±£ÔÚ²úÉúÁËÖµµÄ²éѯ֮ºóÁ¢¼´µ÷Óà <function>mysql_insert_id</function>¡£ </para> <note> <para> MySQL ÖÐµÄ SQL º¯Êý <literal>LAST_INSERT_ID()</literal> ×ÜÊDZ£´æ×Å×îвúÉúµÄ AUTO_INCREMENT Öµ£¬²¢ÇÒ²»»áÔÚ²éѯÓï¾äÖ®¼ä±»ÖØÖᣠ</para> </note> <warning> <para> <function>mysql_insert_id</function> ½« MySQL ÄÚ²¿µÄ C API º¯Êý <literal>mysql_insert_id()</literal> µÄ·µ»ØÖµ×ª»»³É <literal>long</literal>£¨PHP ÖÐÃüÃûΪ <type>int</type>£©¡£Èç¹û AUTO_INCREMENT µÄÁеÄÀàÐÍÊÇ BIGINT£¬Ôò <function>mysql_insert_id</function> ·µ»ØµÄÖµ½«²»ÕýÈ·¡£¿ÉÒÔÔÚ SQL ²éѯÖÐÓà MySQL ÄÚ²¿µÄ SQL º¯Êý <literal>LAST_INSERT_ID()</literal> À´Ìæ´ú¡£ </para> </warning> <example> <title>mysql_insert_id Àý×Ó</title> <programlisting role="php"> <![CDATA[ <?php mysql_connect("localhost", "mysql_user", "mysql_password") or die("Could not connect: " . mysql_error()); mysql_select_db("mydb"); mysql_query("INSERT INTO mytable (product) values ('kossu')"); printf ("Last inserted record has id %d\n", mysql_insert_id()); ?> ]]> </programlisting> </example> <para> ²Î¼û <function>mysql_query</function>¡£ </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-zh/reference/mysql/functions/mysql-list-dbs.xml +++ phpdoc-zh/reference/mysql/functions/mysql-list-dbs.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.3 Maintainer: dallas Status: ready --> <refentry id="function.mysql-list-dbs"> <refnamediv> <refname>mysql_list_dbs</refname> <refpurpose> Áгö MySQL ·þÎñÆ÷ÖÐËùÓеÄÊý¾Ý¿â </refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>resource</type><methodname>mysql_list_dbs</methodname> <methodparam choice="opt"><type>resource</type><parameter> link_identifier </parameter></methodparam> </methodsynopsis> <para> <function>mysql_list_dbs</function> ½«·µ»ØÒ»¸ö½á¹ûÖ¸Õ룬°üº¬Á˵±Ç° MySQL ½ø³ÌÖÐËùÓпÉÓõÄÊý¾Ý¿â¡£Óà <function>mysql_tablename</function> º¯ÊýÀ´±éÀú´Ë½á¹ûÖ¸Õ룬»òÕßÈκÎʹÓýá¹û±íµÄº¯Êý£¬ÀýÈç <function>mysql_fetch_array</function>¡£ </para> <para> <example> <title><function>mysql_list_dbs</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); $db_list = mysql_list_dbs($link); while ($row = mysql_fetch_object($db_list)) { echo $row->Database . "\n"; } ?> ]]> </programlisting> <para> ÒÔÉÏÀý×Ó½«²úÉúÈçÏÂÊä³ö£º <screen> <![CDATA[ database1 database2 database3 ... ]]> </screen> </para> </example> </para> <note> <para> ÒÔÉÏ´úÂëÓÃÆðÀ´ºÍ <function>mysql_fetch_row</function> »òÀàËÆº¯ÊýÒ»Ñù¼òµ¥¡£ </para> </note> <para> ΪÏòϼæÈÝÈÔÈ»¿ÉÒÔʹÓà <function>mysql_listdbs</function>£¬µ«·´¶ÔÕâÑù×ö¡£ </para> <para> ²Î¼û <function>mysql_db_name</function>¡£ </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-zh/reference/mysql/functions/mysql-list-fields.xml +++ phpdoc-zh/reference/mysql/functions/mysql-list-fields.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.3 Maintainer: dallas Status: ready --> <refentry id="function.mysql-list-fields"> <refnamediv> <refname>mysql_list_fields</refname> <refpurpose>Áгö MySQL ±íÖеÄ×Ö¶Î</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>resource</type><methodname>mysql_list_fields</methodname> <methodparam><type>string</type><parameter>database_name</parameter></methodparam> <methodparam><type>string</type><parameter>table_name</parameter></methodparam> <methodparam choice="opt"><type>resource</type><parameter> link_identifier </parameter></methodparam> </methodsynopsis> <para> <function>mysql_list_fields</function> È¡µÃ¸ø¶¨±íÃûµÄÐÅÏ¢¡£²ÎÊýÊÇÊý¾Ý¿âÃûºÍ±íÃû¡£·µ»ØÒ»¸ö½á¹ûÖ¸Õ룬¿ÉÒÔÓÃÓÚ <function>mysql_field_flags</function>£¬<function>mysql_field_len</function>£¬<function>mysql_field_name</function> ºÍ <function>mysql_field_type</function>¡£ </para> <para> <example> <title><function>mysql_list_fields</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); $fields = mysql_list_fields("database1", "table1", $link); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { echo mysql_field_name($fields, $i) . "\n"; } ]]> </programlisting> <para> ÒÔÉÏÀý×Ó½«²úÉúÈçÏÂÊä³ö£º <screen> <![CDATA[ field1 field2 field3 ... ]]> </screen> </para> </example> </para> <para> ΪÏòϼæÈÝÈÔÈ»¿ÉÒÔʹÓà <function>mysql_listfields</function>£¬µ«·´¶ÔÕâÑù×ö¡£ </para> <!-- TODO: this is equiv. with 'select * from $table where &false;,' which implies you can better use the field-research functions on a real query, that saves you one mysql-query. --> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-zh/reference/mysql/functions/mysql-list-processes.xml +++ phpdoc-zh/reference/mysql/functions/mysql-list-processes.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.2 Maintainer: dallas Status: ready --> <refentry id="function.mysql-list-processes"> <refnamediv> <refname>mysql_list_processes</refname> <refpurpose>Áгö MySQL ½ø³Ì</refpurpose> </refnamediv> <refsect1> <title>˵Ã÷</title> <methodsynopsis> <type>resource</type><methodname>mysql_list_processes</methodname> <methodparam choice="opt"><type>resource</type><parameter> link_identifier </parameter></methodparam> </methodsynopsis> <para> <function>mysql_list_processes</function> ·µ»ØÒ»¸ö½á¹ûÖ¸Õ룬˵Ã÷Á˵±Ç°·þÎñÆ÷µÄÏ̡߳£ </para> <para> <example> <title><function>mysql_list_processes</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ <?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); $result = mysql_list_processes($link); while ($row = mysql_fetch_row($result)){ printf("%s %s %s %s %s\n", $row["Id"], $row["Host"], $row["db"], $row["Command"], $row["Time"]); } mysql_free_result ($result); ?> ]]> </programlisting> <para> ÒÔÉÏÀý×Ó½«²úÉúÈçÏÂÊä³ö£º <screen> <![CDATA[ 1 localhost test Processlist 0 4 localhost mysql sleep 5 ]]> </screen> </para> </example> </para> <para> ²Î¼û <function>mysql_thread_id</function>¡£ </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> Index: phpdoc-zh/reference/mysql/functions/mysql-list-tables.xml +++ phpdoc-zh/reference/mysql/functions/mysql-list-tables.xml <?xml version="1.0" encoding="gb2312"?> <!-- $Revision: 1.1 $ --> <!-- $Author: dallas $ --> <!-- EN-Revision: 1.5 Maintainer: dallas Status: ready --> <refentry id="function.mysql-list-tables"> <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> <example> <title><function>mysql_list_tables</function> Àý×Ó</title> <programlisting role="php"> <![CDATA[ <?php $dbname = 'mysql_dbname'; if (!mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) { print 'Could not connect to mysql'; exit; } $result = mysql_list_tables($dbname); if (!$result) { print "DB Error, could not list tables\n"; print 'MySQL Error: ' . mysql_error(); exit; } while ($row = mysql_fetch_row($result)) { print "Table: $row[0]\n"; } mysql_free_result($result); ?> ]]> </programlisting> </example> <para> ²Î¼û <function>mysql_list_dbs</function> ºÍ <function>mysql_tablename</function>¡£ </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.doc.zh (#1153) next »