No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

mysqli_stmt::get_result

mysqli_stmt_get_result

(PHP 5 >= 5.3.0, PHP 7)

mysqli_stmt::get_result -- mysqli_stmt_get_resultGets a result set from a prepared statement

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

Description

Object oriented style

mysqli_stmt::get_result ( void ) : mysqli_result

Procedural style

mysqli_stmt_get_result ( mysqli_stmt $stmt ) : mysqli_result

Call to return a result set from a prepared statement query.

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

Parameters

stmt

Procedural style only: A statement identifier returned by mysqli_stmt_init().

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns a resultset for successful SELECT queries, or FALSE for other DML queries or on failure. The mysqli_errno() function can be used to distinguish between the two types of failure.

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

MySQL Native Driver Only

Available only with mysqlnd.

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 Object oriented style

<?php 

$mysqli 
= new mysqli("127.0.0.1""user""password""world"); 

if(
$mysqli->connect_error)
{
    die(
"$mysqli->connect_errno$mysqli->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();
?>

Example #2 Procedural style

<?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($resultMYSQLI_NUM))
        {
            foreach (
$row as $r)
            {
                print 
"$r ";
            }
            print 
"\n";
        }
    }
}
mysqli_stmt_close($stmt);
mysqli_close($link);
?>

The above examples will output:

Albania 3401200 Europe 
Algeria 31471000 Africa 
Afghanistan 22720000 Asia 
Anguilla 8000 North America 

PHP: mysqli_stmt::get_result - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-mysqli-stmt.get-result.html/.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut