diff --git a/reference/mysql/functions/mysql-info.xml b/reference/mysql/functions/mysql-info.xml index 78646bafe..7d32382c8 100644 --- a/reference/mysql/functions/mysql-info.xml +++ b/reference/mysql/functions/mysql-info.xml @@ -1,63 +1,96 @@ - - - - - mysql_info - - 取得最近一条查询的信息 - - - - 说明 - - stringmysql_info - resourcelink_identifier - + + + + + mysql_info + 获取最近查询的有关信息 + + + + + &mysql.alternative.note; + + mysqli_info + + + + + + &reftitle.description; + + stringmysql_info + resourcelink_identifierNULL + + + 返回最近一条查询的详细信息。 + + + + + &reftitle.parameters; + + + &mysql.linkid.description; + + + + + + &reftitle.returnvalues; + + 在成功时返回语句信息,在失败时返回 &false;。请查看下面的示例,了解哪些语句提供信息,以及返回值可能是什么样子。未列出的语句将返回 &false;。 + + + + + &reftitle.examples; + + + 相关的 MySQL 语句 - mysql_info - 返回通过给定的 - link_identifier - 所进行的最新一条查询的详细信息。如果没有指定 - link_identifier,则假定为上一个打开的连接。 + 返回字符串值的语句。这些数字仅用于说明目的;它们的值将与查询相对应。 - - mysql_info - 对以下列出的所有语句返回一个字符串。对于其它任何语句返回 - &false;。字符串的格式取决于给出的语句。 - - 相关的 MySQL 语句 - + - - - 上例中的数字只是为了演示的目的,实际的值取决于查询。 - - - - mysql_info - 对于 - INSERT ... VALUES - 语句仅在该语句中列出了多个值的情况下返回一个非 &false; 的值。 - - - - 参见 mysql_affected_rows。 - - - + + + + + + + &reftitle.notes; + + + mysql_info 对于 INSERT ... VALUES + 语句仅在该语句中列出了多个值的情况下返回非 &false; 的值。 + + + + + + &reftitle.seealso; + + + mysql_affected_rows + mysql_insert_id + mysql_stat + + + + - - - - - mysql_insert_id - - 取得上一步 INSERT 操作产生的 ID - - - - 说明 - - intmysql_insert_id - resourcelink_identifier - - - mysql_insert_id - 返回给定的 - link_identifier - 中上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号。如果没有指定 - link_identifier,则使用上一个打开的连接。 - - - 如果上一查询没有产生 - AUTO_INCREMENT 的值,则 - mysql_insert_id - 返回 0。如果需要保存该值以后使用,要确保在产生了值的查询之后立即调用 - mysql_insert_id。 - - - - MySQL 中的 SQL 函数 - LAST_INSERT_ID() - 总是保存着最新产生的 - AUTO_INCREMENT 值,并且不会在查询语句之间被重置。 - - - - - mysql_insert_id 将 - MySQL 内部的 C API 函数 - mysql_insert_id() - 的返回值转换成 - long(PHP 中命名为 int)。如果 - AUTO_INCREMENT 的列的类型是 BIGINT,则 - mysql_insert_id - 返回的值将不正确。可以在 SQL 查询中用 - MySQL 内部的 SQL 函数 - LAST_INSERT_ID() 来替代。 - - - - - <function>mysql_insert_id</function> 例子 - + + + + + mysql_insert_id + 取得上一条查询生成的 ID + + + + + &mysql.alternative.note; + + mysqli_insert_id + PDO::lastInsertId + + + + + + &reftitle.description; + + intmysql_insert_id + resourcelink_identifierNULL + + + 检索通过之前查询(通常是 INSERT)中 AUTO_INCREMENT 列生成的 ID。 + + + + + &reftitle.parameters; + + + &mysql.linkid.description; + + + + + + &reftitle.returnvalues; + + 成功时返回通过之前查询中 AUTO_INCREMENT 列生成的 ID,如果之前查询没有生成 AUTO_INCREMENT + 值,则为 0。如果没有建立 MySQL 连接,则为 &false;。 + + + + + &reftitle.examples; + + + <function>mysql_insert_id</function> 示例 + ]]> - - - - - 参见 mysql_query。 - - - + + + + + + + &reftitle.notes; + + + mysql_insert_id will convert the return type of the + native MySQL C API function mysql_insert_id() to a type + of long (named int in PHP). If your + AUTO_INCREMENT column has a column type of BIGINT (64 bits) the + conversion may result in an incorrect value. Instead, use the internal + MySQL SQL function LAST_INSERT_ID() in an SQL query. For more information + about PHP's maximum integer values, please see the + integer documentation. + + + + + Because mysql_insert_id acts on the last performed + query, be sure to call mysql_insert_id immediately + after the query that generates the value. + + + + + The value of the MySQL SQL function + LAST_INSERT_ID() always contains the most + recently generated AUTO_INCREMENT value, and is not reset + between queries. + + + + + + &reftitle.seealso; + + + mysql_query + mysql_info + + + + - - - - - mysql_result - 取得结果数据 - - - 说明 - - mixedmysql_result - resourceresult - introw - mixedfield - - - mysql_result 返回 MySQL - 结果集中一个单元的内容。字段参数可以是字段的偏移量或者字段名,或者是字段表点字段名(tablename.fieldname)。如果给列起了别名('select - foo as bar from...'),则用别名替代列名。 - - - 当作用于很大的结果集时,应该考虑使用能够取得整行的函数(在下边指出)。这些函数在一次函数调用中返回了多个单元的内容,比 - mysql_result - 快得多。此外注意在字段参数中指定数字偏移量比指定字段名或者 - tablename.fieldname 要快得多。 - - - 调用 mysql_result - 不能和其它处理结果集的函数混合调用。 - - - - <function>mysql_result</function> 例子 - - + + + + mysql_result + 取得结果数据 + + + + + &mysql.alternative.note; + + + mysqli_data_seek 与 + mysqli_field_seek 和 + mysqli_fetch_field 结合使用 + + PDOStatement::fetchColumn + + + - $result = mysql_query("SELECT name FROM work.employee") - or die("Could not query: . mysql_error()); + + &reftitle.description; + + stringmysql_result + resourceresult + introw + mixedfield0 + + + Retrieves the contents of one cell from a MySQL result set. + + + When working on large result sets, you should consider using one + of the functions that fetch an entire row (specified below). As + these functions return the contents of multiple cells in one + function call, they're MUCH quicker than + mysql_result. Also, note that specifying a + numeric offset for the field argument is much quicker than + specifying a fieldname or tablename.fieldname argument. + + - echo mysql_result($result,2); // outputs third employee's name + + &reftitle.parameters; + + + &mysql.result.description; + + row + + + The row number from the result that's being retrieved. Row numbers + start at 0. + + + + + field + + + The name or offset of the field being retrieved. + + + It can be the field's offset, the field's name, or the field's table + dot field name (tablename.fieldname). If the column name has been + aliased ('select foo as bar from...'), use the alias instead of the + column name. If undefined, the first field is retrieved. + + + + + + - mysql_close($link); + + &reftitle.returnvalues; + + The contents of one cell from a MySQL result set on success, or + &false; on failure. + + + + + &reftitle.examples; + + + <function>mysql_result</function> 示例 + + ]]> - - - - - 推荐使用高性能的替代函数:mysql_fetch_rowmysql_fetch_arraymysql_fetch_assoc - 和 mysql_fetch_object。 - - - + + + + + + + &reftitle.notes; + + + Calls to mysql_result should not be mixed + with calls to other functions that deal with the result set. + + + + + + &reftitle.seealso; + + + mysql_fetch_row + mysql_fetch_array + mysql_fetch_assoc + mysql_fetch_object + + + +