From 8ad868325ad3a44028be2cb122646fd9926dc00e Mon Sep 17 00:00:00 2001 From: Egon Schmid Date: Sat, 10 Jun 2000 17:36:51 +0000 Subject: [PATCH] Added a example for mysql_fetch_field(). Not tested but jade is still happy. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@26014 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/mysql.xml | 48 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/functions/mysql.xml b/functions/mysql.xml index 0d4a289cb7..66170009f5 100644 --- a/functions/mysql.xml +++ b/functions/mysql.xml @@ -533,16 +533,16 @@ select t1.f1 as foo t2.f1 as bar from t1, t2 mysql_fetch_row. - mysql fetch array + <function>Mysql_fetch_array</function> <?php -mysql_connect($host,$user,$password); -$result = mysql_db_query("database","select * from table"); -while($row = mysql_fetch_array($result)) { +mysql_connect ($host, $user, $password); +$result = mysql_db_query ("database","select * from table"); +while ($row = mysql_fetch_array ($result)) { echo $row["user_id"]; echo $row["fullname"]; } -mysql_free_result($result); +mysql_free_result ($result); ?> @@ -641,8 +641,44 @@ mysql_free_result($result); + + <function>Mysql_fetch_field</function> + +<?php +mysql_connect ($host, $user, $password) + or die ("Could not connect"); +$result = mysql_db_query ("database", "select * from table") + or die ("Query failed"); +# get column metadata +$i = 0; +while ($i $lt; mysql_num_fields ($result)) { + echo "Information for column $i:<BR>\n"; + $meta = mysql_fetch_field ($result); + if (!$meta) { + echo "No information available<BR>\n"; + } + echo "<PRE> +blob: $meta -> blob +max_length: $meta -> max_length +multiple_key: $meta -> multiple_key +name: $meta -> name +not_null: $meta -> not_null +numeric: $meta -> numeric +primary_key: $meta -> primary_key +table: $meta -> table +type: $meta -> type +unique_key: $meta -> unique_key +unsigned: $meta -> unsigned +zerofill: $meta -> zerofill +</PRE>"; + $i++; +} +mysql_free_result ($result); +?> + + - See also mysql_field_seek + See also mysql_field_seek.