php-doc-en/reference/mysql/functions/mysql-result.xml
Adam Harvey 65e697ff67 Officially deprecate ext/mysql in the manual.
Specific changes:

- Upgraded the soft deprecation sidebars to full blown warnings.
- Beefed up the wording of the soft deprecation notice boilerplate.
- Added changelog items for mysql_connect() and mysql_pconnect(), since they're
  the functions that have changed behaviour.
- Updated the MySQL changelog.
- Updated the 5.5 migration guide.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@328734 c90b9560-bf6c-de11-be94-00142212c4b1
2012-12-10 15:22:07 +00:00

156 lines
4.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mysql-result" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysql_result</refname>
<refpurpose>Get result data</refpurpose>
</refnamediv>
<refsynopsisdiv>
<warning>
&mysql.alternative.note;
<simplelist role="alternatives">
<member>
<function>mysqli_data_seek</function> in conjunction with
<function>mysqli_field_seek</function> and
<function>mysqli_fetch_field</function>
</member>
<member><methodname>PDOStatement::fetchColumn</methodname></member>
</simplelist>
</warning>
</refsynopsisdiv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>mysql_result</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><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
Retrieves the contents of one cell from a MySQL result set.
</para>
<para>
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
<function>mysql_result</function>. Also, note that specifying a
numeric offset for the field argument is much quicker than
specifying a fieldname or tablename.fieldname argument.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&mysql.result.description;
<varlistentry>
<term><parameter>row</parameter></term>
<listitem>
<para>
The row number from the result that's being retrieved. Row numbers
start at <literal>0</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>field</parameter></term>
<listitem>
<para>
The name or offset of the field being retrieved.
</para>
<para>
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.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The contents of one cell from a MySQL result set on success, or
&false; on failure.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>mysql_result</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (!mysql_select_db('database_name')) {
die('Could not select database: ' . mysql_error());
}
$result = mysql_query('SELECT name FROM work.employee');
if (!$result) {
die('Could not query:' . mysql_error());
}
echo mysql_result($result, 2); // outputs third employee's name
mysql_close($link);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<note>
<para>
Calls to <function>mysql_result</function> should not be mixed
with calls to other functions that deal with the result set.
</para>
</note>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysql_fetch_row</function></member>
<member><function>mysql_fetch_array</function></member>
<member><function>mysql_fetch_assoc</function></member>
<member><function>mysql_fetch_object</function></member>
</simplelist>
</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:"~/.phpdoc/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
-->