mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
changed example and inserted <screen> section for output
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@79380 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
42463aad89
commit
a63410b81f
1 changed files with 31 additions and 20 deletions
|
@ -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.2 -->
|
||||
<refentry id="function.mysql-field-type">
|
||||
<refnamediv>
|
||||
|
@ -27,28 +27,39 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
mysql_connect("localhost:3306");
|
||||
mysql_select_db("wisconsin");
|
||||
$result = mysql_query("SELECT * FROM onek");
|
||||
$fields = mysql_num_fields($result);
|
||||
$rows = mysql_num_rows($result);
|
||||
$i = 0;
|
||||
$table = mysql_field_table($result, $i);
|
||||
echo "Your '".$table."' table has ".$fields." fields and ".$rows." records <br />";
|
||||
echo "The table has the following fields <br />";
|
||||
while ($i < $fields) {
|
||||
$type = mysql_field_type($result, $i);
|
||||
$name = mysql_field_name($result, $i);
|
||||
$len = mysql_field_len($result, $i);
|
||||
$flags = mysql_field_flags($result, $i);
|
||||
echo $type." ".$name." ".$len." ".$flags."<br />";
|
||||
$i++;
|
||||
}
|
||||
mysql_close();
|
||||
|
||||
mysql_connect("localhost", "mysql_username", "mysql_password");
|
||||
mysql_select_db("mysql");
|
||||
$result = mysql_query("SELECT * FROM func");
|
||||
$fields = mysql_num_fields($result);
|
||||
$rows = mysql_num_rows($result);
|
||||
$table = mysql_field_table($result, 0);
|
||||
echo "Your '".$table."' table has ".$fields." fields and ".$rows." record(s)\n";
|
||||
echo "The table has the following fields:\n";
|
||||
for ($i=0; $i < $fields; $i++) {
|
||||
$type = mysql_field_type($result, $i);
|
||||
$name = mysql_field_name($result, $i);
|
||||
$len = mysql_field_len($result, $i);
|
||||
$flags = mysql_field_flags($result, $i);
|
||||
echo $type." ".$name." ".$len." ".$flags."\n";
|
||||
}
|
||||
mysql_free_result($result);
|
||||
mysql_close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The abouve example would produce the following output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Your 'func' table has 4 fields and 1 record(s)
|
||||
The table has the following fields:
|
||||
string name 64 not_null primary_key binary
|
||||
int ret 1 not_null
|
||||
string dl 128 not_null
|
||||
string type 9 not_null enum
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue