Add docs for mysqli_stmt_get_result. Fixes #34948

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@309605 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Anthony Bedford 2011-03-23 15:29:35 +00:00
parent 0d94f00367
commit 0b995c96a3

View file

@ -0,0 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: $ -->
<refentry xml:id="mysqli-stmt.get-result" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>mysqli_stmt::get_result</refname>
<refname>mysqli_stmt_get_result</refname>
<refpurpose>Gets a result set from a prepared statement</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>&style.oop;</para>
<methodsynopsis>
<type>bool</type><methodname>mysqli_stmt::get_result</methodname>
<void />
</methodsynopsis>
<para>&style.procedural;</para>
<methodsynopsis>
<type>bool</type><methodname>mysqli_stmt_get_result</methodname>
<methodparam><type>mysqli_stmt</type><parameter>stmt</parameter></methodparam>
</methodsynopsis>
<para>
Call to return a result set from a prepared statement query.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&mysqli.stmt.description;
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a resultset.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<para>&style.oop;</para>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("127.0.0.1", "user", "password", "world");
if($mysqli->connect_error)
{
die("$mysqli->connect_errno: $myslqi->connect_error");
}
$query = "SELECT Name, Population, Continent FROM Country WHERE Continent=? ORDER BY Name LIMIT 1";
$stmt = $mysqli->stmt_init();
if(!$stmt->prepare($query))
{
print "Failed to prepare statement\n";
}
else
{
$stmt->bind_param("s", $continent);
$continent_array = array('Europe','Africa','Asia','North America');
foreach($continent_array as $continent)
{
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_array(MYSQLI_NUM))
{
foreach ($row as $r)
{
print "$r ";
}
print "\n";
}
}
}
$stmt->close();
$mysqli->close();
?>
]]>
</programlisting>
<para>&style.procedural;</para>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("127.0.0.1", "user", "password", "world");
if (!$link)
{
$error = mysqli_connect_error();
$errno = mysqli_connect_errno();
print "$errno: $error\n";
exit();
}
$query = "SELECT Name, Population, Continent FROM Country WHERE Continent=? ORDER BY Name LIMIT 1";
$stmt = mysqli_stmt_init($link);
if(!mysqli_stmt_prepare($stmt, $query))
{
print "Failed to prepare statement\n";
}
else
{
mysqli_stmt_bind_param($stmt, "s", $continent);
$continent_array = array('Europe','Africa','Asia','North America');
foreach($continent_array as $continent)
{
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_array($result, MYSQLI_NUM))
{
foreach ($row as $r)
{
print "$r ";
}
print "\n";
}
}
}
mysqli_stmt_close($stmt);
mysqli_close($link);
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
Albania 3401200 Europe
Algeria 31471000 Africa
Afghanistan 22720000 Asia
Anguilla 8000 North America
]]>
</screen>
</example>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysqli_prepare</function></member>
<member><function>mysqli_stmt_result_metadata</function></member>
<member><function>mysqli_stmt_fetch</function></member>
<member><function>mysqli_fetch_array</function></member>
<member><function>mysqli_stmt_store_result</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
-->