svn: /phpdoc/en/trunk/reference/mysqli/mysqli_stmt/ get-result.xml

From: Date: Wed, 23 Mar 2011 15:29:35 +0000
Subject: svn: /phpdoc/en/trunk/reference/mysqli/mysqli_stmt/ get-result.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-7889@lists.php.net to get a copy of this message
abedford Wed, 23 Mar 2011 15:29:35 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=309605 Log: Add docs for mysqli_stmt_get_result. Fixes #34948 Bug: http://bugs.php.net/34948 (To be documented) mysqli_statement and binding array Changed paths: A phpdoc/en/trunk/reference/mysqli/mysqli_stmt/get-result.xml Added: phpdoc/en/trunk/reference/mysqli/mysqli_stmt/get-result.xml =================================================================== --- phpdoc/en/trunk/reference/mysqli/mysqli_stmt/get-result.xml (rev 0) +++ phpdoc/en/trunk/reference/mysqli/mysqli_stmt/get-result.xml 2011-03-23 15:29:35 UTC (rev 309605) @@ -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 +-->

« previous php.doc.cvs (#7889) next »