Added an example, and see also.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@163326 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2004-07-14 21:08:10 +00:00
parent c23c764146
commit a2589d4f6a
5 changed files with 144 additions and 6 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-fetch-lengths">
<refnamediv>
@ -23,12 +23,50 @@
<function>mysql_fetch_lengths</function> stores the lengths of
each result column in the last row returned by
<function>mysql_fetch_row</function>,
<function>mysql_fetch_assoc</function>,
<function>mysql_fetch_array</function>, and
<function>mysql_fetch_object</function> in an array, starting at
offset 0.
</para>
<para>
See also <function>mysql_fetch_row</function>.
<example>
<title>A <function>mysql_fetch_lengths</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_assoc($result);
$lengths = mysql_fetch_lengths($result);
print_r($row);
print_r($lengths);
/* Output will look similar to:
Array
(
[id] => 42
[email] => user@example.com
)
Array
(
[0] => 2
[1] => 16
)
*/
?>
]]>
</programlisting>
</example>
</para>
<para>
See also <function>mysql_fetch_len</function>,
<function>mysql_fetch_row</function>, and
<function>strlen</function>.
</para>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-fetch-row">
<refnamediv>
@ -27,6 +27,26 @@
return the next row in the result set, or &false; if there are no
more rows.
</para>
<para>
<example>
<title>Fetching one row with <function>mysql_fetch_row</function></title>
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$row = mysql_fetch_row($result);
echo $row[0]; // 42
echo $row[1]; // the email value
?>
]]>
</programlisting>
</example>
</para>
<para>
See also
<function>mysql_fetch_array</function>,

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.17 -->
<refentry id="function.mysql-field-flags">
<refnamediv>
@ -26,6 +26,38 @@
"unique_key", "multiple_key", "blob", "unsigned", "zerofill",
"binary", "enum", "auto_increment", "timestamp".
</para>
<para>
<example>
<title>A <function>mysql_field_flags</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
$flags = mysql_field_flags($result, 'id');
print $flags;
print_r(explode(' ', $flags));
/* Output will look similar to:
not_null primary_key auto_increment
Array
(
[0] => not_null
[1] => primary_key
[2] => auto_increment
)
*/
?>
]]>
</programlisting>
</example>
</para>
<para>
For downward compatibility <function>mysql_fieldflags</function>
can also be used. This is deprecated, however.

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.17 -->
<refentry id="function.mysql-field-len">
<refnamediv>
@ -19,10 +19,35 @@
<function>mysql_field_len</function> returns the length of the
specified field.
</para>
<para>
<example>
<title>A <function>mysql_fetch_len</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
// Will get the length of the value in email so for example
// user@example.com would give us a length of 16
$length = mysql_fetch_len($result, 'email');
echo $length;
?>
]]>
</programlisting>
</example>
</para>
<para>
For downward compatibility <function>mysql_fieldlen</function>
can also be used. This is deprecated, however.
</para>
<para>
See also <function>mysql_fetch_lengths</function> and
<function>strlen</function>.
</para>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/mysql.xml, last change in rev 1.2 -->
<refentry id="function.mysql-field-table">
<refnamediv>
@ -19,10 +19,33 @@
Returns the name of the table that the specified field is
in.
</para>
<para>
<example>
<title>A <function>mysql_field_table</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$result = mysql_query("SELECT name,comment FROM people,comments");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
// Assuming name is in the people table
$table = mysql_field_table($result, 'name');
echo $table; // people
?>
]]>
</programlisting>
</example>
</para>
<para>
For downward compatibility <function>mysql_fieldtable</function>
can also be used. This is deprecated, however.
</para>
<para>
See also <function>mysql_list_tables</function>.
</para>
</refsect1>
</refentry>