mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
added more samples
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@152070 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
51dbae9fc3
commit
3eb2dcea98
10 changed files with 722 additions and 23 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.mysqli-fetch-field-direct">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_field_direct</refname>
|
||||
|
@ -37,6 +37,57 @@
|
|||
Returns an object which contains field definition informations or &false; if no field information
|
||||
for specified <literal>fieldnr</literal> is available.
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
<title>Object attributes</title>
|
||||
<tgroup cols='2'>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>The name of the column</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>orgname</entry>
|
||||
<entry>Original column name if an alias was specified</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table</entry>
|
||||
<entry>The name of the table this field belongs to (if not calculated)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>orgtable</entry>
|
||||
<entry>Original table name if an alias was specified</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>def</entry>
|
||||
<entry>The default value for this field, represented as a string</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>max_length</entry>
|
||||
<entry>The maximum width of the field for the result set.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>flags</entry>
|
||||
<entry>An integer representing the bit-flags for the field.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>type</entry>
|
||||
<entry>The data type used for this field</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>decimals</entry>
|
||||
<entry>The number of decimals used (for integer fields)</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.mysqli-fetch-field">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_field</refname>
|
||||
|
@ -29,6 +29,13 @@
|
|||
the attributes of the current column or &false; if there are no more columns in the
|
||||
result set.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Return values</title>
|
||||
<para>
|
||||
Returns an object which contains field definition informations or &false; if no field information
|
||||
is available.
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
<title>Object attributes</title>
|
||||
|
@ -81,21 +88,82 @@
|
|||
</table>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Return values</title>
|
||||
<para>
|
||||
Returns an object which contains field definition informations or &false; if no field information
|
||||
is available.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<function>mysqli_num_fields</function>
|
||||
<function>mysqli_fetch_field_direct</function>
|
||||
<function>mysqli_fetch_fields</function>
|
||||
<function>mysqli_field_seek</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
/* Get field information for all columns */
|
||||
while ($finfo = $result->fetch_field()) {
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
}
|
||||
|
||||
$result->close();
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* Get field information for all columns */
|
||||
while ($finfo = mysqli_fetch_field($result)) {
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
}
|
||||
|
||||
mysqli_free_result($result);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.mysqli-fetch-fields">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_fields</refname>
|
||||
|
@ -36,6 +36,57 @@
|
|||
Returns an array of objects which contains field definition informations or &false; if no field information
|
||||
is available.
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
<title>Object attributes</title>
|
||||
<tgroup cols='2'>
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Attribute</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>The name of the column</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>orgname</entry>
|
||||
<entry>Original column name if an alias was specified</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>table</entry>
|
||||
<entry>The name of the table this field belongs to (if not calculated)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>orgtable</entry>
|
||||
<entry>Original table name if an alias was specified</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>def</entry>
|
||||
<entry>The default value for this field, represented as a string</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>max_length</entry>
|
||||
<entry>The maximum width of the field for the result set.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>flags</entry>
|
||||
<entry>An integer representing the bit-flags for the field.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>type</entry>
|
||||
<entry>The data type used for this field</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>decimals</entry>
|
||||
<entry>The number of decimals used (for integer fields)</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
|
@ -45,6 +96,77 @@
|
|||
<function>mysqli_fetch_field_direct</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* Get field informations */
|
||||
$finfo = mysqli_fetch_fields($result);
|
||||
|
||||
for ($i=0; $i < count($finfo); $i++) {
|
||||
printf("Name: %s\n", $finfo[$i]->name);
|
||||
printf("Table: %s\n", $finfo[$i]->table);
|
||||
printf("Default: %s\n", $finfo[$i]->def);
|
||||
printf("max. Len: %d\n", $finfo[$i]->max_length);
|
||||
printf("Flags: %d\n", $finfo[$i]->flags);
|
||||
printf("Type: %d\n", $finfo[$i]->type);
|
||||
}
|
||||
|
||||
mysqli_free_result($result);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
/* Get field information for column 'name' */
|
||||
$finfo = $result->fetch_fields();
|
||||
|
||||
for ($i=0; $i < count($finfo); $i++) {
|
||||
printf("Name: %s\n", $finfo[$i]->name);
|
||||
printf("Table: %s\n", $finfo[$i]->table);
|
||||
printf("Default: %s\n", $finfo[$i]->def);
|
||||
printf("max. Len: %d\n", $finfo[$i]->max_length);
|
||||
printf("Flags: %d\n", $finfo[$i]->flags);
|
||||
printf("Type: %d\n", $finfo[$i]->type);
|
||||
}
|
||||
|
||||
$result->close();
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.mysqli-fetch-lengths">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_lengths</refname>
|
||||
<refname>result->fetch_lengths</refname>
|
||||
<refname>result->lengths</refname>
|
||||
<refpurpose>Returns the lengths of the columns of the current row in the result set</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -16,7 +16,7 @@
|
|||
<para>Object oriented style (property):</para>
|
||||
<classsynopsis>
|
||||
<ooclass><classname>result</classname></ooclass>
|
||||
<fieldsynopsis><type>mixed</type><varname>fetch_lengths</varname></fieldsynopsis>
|
||||
<fieldsynopsis><type>mixed</type><varname>lengths</varname></fieldsynopsis>
|
||||
</classsynopsis>
|
||||
<para>
|
||||
The <function>mysqli_fetch_lengths</function> function returns an array containing the
|
||||
|
@ -37,6 +37,69 @@
|
|||
all rows in the result.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
$row = $result->fetch_row();
|
||||
|
||||
/* Print field lengths */
|
||||
for ($i=0; $i < count($result->lengths); $i++) {
|
||||
printf("Field %d has length %d\n", $i, $result->lengths[$i]);
|
||||
}
|
||||
|
||||
$result->close();
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
$row = mysqli_fetch_row($result);
|
||||
|
||||
/* Get field lengths */
|
||||
$lengths = mysqli_fetch_lengths($result);
|
||||
|
||||
for ($i=0; $i < count($lengths); $i++) {
|
||||
printf("Field %d has length %d\n", $i, $lengths[$i]);
|
||||
}
|
||||
|
||||
mysqli_free_result($result);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry id="function.mysqli-fetch-object">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_object</refname>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<refsect1>
|
||||
<title>Return values</title>
|
||||
<para>
|
||||
Returns an object or &false; if an error occured.
|
||||
Returns an object that corresponds to the fetched row or &null; if there are no more rows in resultset.
|
||||
</para>
|
||||
&database.field-case;
|
||||
</refsect1>
|
||||
|
@ -43,6 +43,61 @@
|
|||
<function>mysqli_fetch_row</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* fetch object */
|
||||
$obj = mysqli_fetch_object($result);
|
||||
|
||||
printf("Id: %d Name: %s\n", $obj->id, $obj->name);
|
||||
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
/* fetch object */
|
||||
$obj = $result->fetch_object();
|
||||
|
||||
printf("Id: %d Name: %s\n", $obj->id, $obj->name);
|
||||
|
||||
$result->close();
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry id="function.mysqli-fetch-row">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch_row</refname>
|
||||
|
@ -37,7 +37,7 @@
|
|||
<title>Return values</title>
|
||||
<para>
|
||||
<function>mysqli_fetch_row</function> returns an array that corresponds to the fetched row
|
||||
or &false; if there are no more rows in result set.
|
||||
or &null; if there are no more rows in result set.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
|
@ -48,6 +48,61 @@
|
|||
<function>mysqli_fetch_object</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
/* fetch object */
|
||||
$row = $result->fetch_row();
|
||||
|
||||
printf("Id: %d Name: %s\n", $row[0], $row[1]);
|
||||
|
||||
$result->close();
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* fetch object */
|
||||
$row = mysqli_fetch_row($result);
|
||||
|
||||
printf("Id: %d Name: %s\n", $row[0], $row[1]);
|
||||
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry id="function.mysqli-fetch">
|
||||
<refnamediv>
|
||||
<refname>mysqli_fetch</refname>
|
||||
|
@ -70,6 +70,73 @@
|
|||
<function>mysqli_bind_result</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$stmt = $mysqli->prepare( "SELECT id, name FROM friends");
|
||||
|
||||
/* execute statement */
|
||||
$stmt->execute();
|
||||
|
||||
/* bind result variables */
|
||||
$stmt->bind_result($column1, $column2);
|
||||
|
||||
/* fetch result */
|
||||
while ($stmt->fetch()) {
|
||||
printf("Id: %d Name: %s\n", $column1, $column2);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$stmt = mysqli_prepare($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* execute statement */
|
||||
mysqli_execute($stmt);
|
||||
|
||||
/* bind result variables */
|
||||
mysqli_bind_result($stmt, $column1, $column2);
|
||||
|
||||
/* fetch result */
|
||||
while (mysqli_fetch($stmt)) {
|
||||
printf("Id: %d Name: %s\n", $column1, $column2);
|
||||
}
|
||||
|
||||
mysqli_stmt_close($stmt);
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry id="function.mysqli-field-count">
|
||||
<refnamediv>
|
||||
<refname>mysqli_field_count</refname>
|
||||
<refname>mysql->field_cont</refname>
|
||||
<refname>mysql->field_count</refname>
|
||||
<refpurpose>Returns the number of columns for the most recent query</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
|
@ -34,6 +34,74 @@
|
|||
<title>Return values</title>
|
||||
<para>An integer representing the number of fields in a result set</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
|
||||
$mysqli->real_query($HTTP_POST_VARS['query']);
|
||||
|
||||
if (mysql_field_count($link)) {
|
||||
/* this was a select/show or describe query */
|
||||
$result = $mysqli->store_result();
|
||||
|
||||
/* process resultset */
|
||||
$row = $result->fetch_row();
|
||||
|
||||
/* free resultset */
|
||||
$result->close();
|
||||
}
|
||||
|
||||
/* close connection */
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
mysqli_real_query($link, $HTTP_POST_VARS['query']);
|
||||
|
||||
if (mysql_field_count($link)) {
|
||||
/* this was a select/show or describe query */
|
||||
$result = mysqli_store_result($link);
|
||||
|
||||
/* process resultset */
|
||||
$row = mysqli_fetch_row($result);
|
||||
|
||||
/* free resultset */
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
|
||||
/* close connection */
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.mysqli-field-seek">
|
||||
<refnamediv>
|
||||
<refname>mysqli_field_seek</refname>
|
||||
|
@ -39,6 +39,84 @@
|
|||
<function>mysqli_field_seek</function> returns previuos value of field cursor.
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>See also</title>
|
||||
<para>
|
||||
<function>mysqli_fetch_field</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
/* set field pointer to column name */
|
||||
$result->field_seek(1);
|
||||
|
||||
/* fetch field information */
|
||||
$finfo = $result->fetch_field();
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
|
||||
$result->close();
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
/* set field pointer to column name */
|
||||
mysqli_field_seek($result, 1);
|
||||
|
||||
/* fetch field information */
|
||||
$finfo = mysqli_fetch_field($result);
|
||||
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
|
||||
mysqli_free_result($result);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry id="function.mysqli-field-tell">
|
||||
<refnamediv>
|
||||
<refname>mysqli_field_tell</refname>
|
||||
|
@ -42,6 +42,78 @@
|
|||
<function>mysqli_field_seek</function>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1>
|
||||
<title>Example</title>
|
||||
<para>
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
|
||||
|
||||
$mysqli->query( "DROP TABLE IF EXISTS friends");
|
||||
$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = $mysqli->query( "SELECT id, name FROM friends");
|
||||
|
||||
while ($finfo = mysqli_fetch_field($result)) {
|
||||
/* get field pointer position */
|
||||
$fieldnr = mysqli_field_tell($result);
|
||||
printf("Fieldnr: %d\n", $fieldnr);
|
||||
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
}
|
||||
|
||||
$result->close();
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role='php'>
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = mysqli_connect("localhost", "my_user", "my_password", "test");
|
||||
|
||||
mysqli_query($link, "DROP TABLE IF EXISTS friends");
|
||||
mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
|
||||
|
||||
mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
|
||||
|
||||
$result = mysqli_query($link, "SELECT id, name FROM friends");
|
||||
|
||||
while ($finfo = $result->fetch_field()) {
|
||||
/* get field pointer position */
|
||||
$fieldnr = $result->current_field;
|
||||
printf("Fieldnr: %d\n", $fieldnr);
|
||||
printf("Name: %s\n", $finfo->name);
|
||||
printf("Table: %s\n", $finfo->table);
|
||||
printf("Default: %s\n", $finfo->def);
|
||||
printf("max. Len: %d\n", $finfo->max_length);
|
||||
printf("Flags: %d\n", $finfo->flags);
|
||||
printf("Type: %d\n", $finfo->type);
|
||||
}
|
||||
|
||||
mysqli_free_result($result);
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Loading…
Reference in a new issue