downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

mysqli_result::current_field> <mysqli_stmt::store_result
[edit] Last updated: Sat, 07 Jan 2012

view this page in

The MySQLi_Result class

(No version information available, might only be in SVN)

소개

Represents the result set obtained from a query against the database.

변경점

변경점
버전 설명
5.4.0 Iterator support was added, as MySQLi_Result now implements Traversable.

클래스 개요

MySQLi_Result implements Traversable {
/* 프로퍼티 */
int $MySQLi_Result->current_field ;
int $field_count;
array $lengths;
int $num_rows;
/* 메소드 */
int mysqli_field_tell ( mysqli_result $result )
bool mysqli_result::data_seek ( int $offset )
mixed mysqli_result::fetch_all ([ int $resulttype = MYSQLI_NUM ] )
mixed mysqli_result::fetch_array ([ int $resulttype = MYSQLI_BOTH ] )
object mysqli_result::fetch_field_direct ( int $fieldnr )
object mysqli_result::fetch_object ([ string $class_name [, array $params ]] )
mixed mysqli_result::fetch_row ( void )
int mysqli_num_fields ( mysqli_result $result )
bool mysqli_result::field_seek ( int $fieldnr )
void mysqli_result::free ( void )
array mysqli_fetch_lengths ( mysqli_result $result )
int mysqli_num_rows ( mysqli_result $result )
}

Table of Contents



mysqli_result::current_field> <mysqli_stmt::store_result
[edit] Last updated: Sat, 07 Jan 2012
 
add a note add a note User Contributed Notes MySQLi_Result
sinisaculic at gmail dot com 22-Oct-2010 12:28
storing this object in ANY kind will result in storing an empty object... if you try to serialize it dump it or do anything with it you will end up with a empty object.

you have to pull all data out f the object and then store the data... no other way.
Anonymous 19-Apr-2010 09:09
Generally, it appears Mysqli OO vs Procedural style has no significant difference in speed, at least with the more generally used functions and methods (connect, close, query, free, etc).

With the fetch_* family of functions and methods dealing with result rows, however, Procedural wins out.  Averaging over a hundred or so tests with a result set of 180,000 records, and using mysqli_fetch_*() functions vs. their mysqli_result::fetch_*() counterpart object methods to read and iterate over all records, all of the mysqli_fetch_*() functions win by ~0.1 seconds less.

This is interesting considering we're dealing with the same result object in both styles.

This was using Vistax64, PHP5.3.2, Mysql 5.1.45, using a bit of this code:

<?php

// procedural - takes 0.1 seconds less than OO here
$stopwatch = microtime(true);
while(
$row = mysqli_fetch_assoc($result)){
    ++
$z;
    }
echo
microtime(true) - $stopwatch;

// OO
$stopwatch = microtime(true);
while(
$row = $result->fetch_assoc()){
    ++
$z;
    }
echo
microtime(true) - $stopwatch;

?>
blar at blar dot de 08-Jan-2009 01:17
Extending the MySQLi_Result

<?php

class Database_MySQLi extends MySQLi
{
    public function
query($query)
    {
       
$this->real_query($query);
        return new
Database_MySQLi_Result($this);
    }
}

class
Database_MySQLi_Result extends MySQLi_Result
{
    public function
fetch()
    {
        return
$this->fetch_assoc();
    }

    public function
fetchAll()
    {
       
$rows = array();
        while(
$row = $this->fetch())
        {
           
$rows[] = $row;
        }
        return
$rows;
    }
}

?>

 
show source | credits | sitemap | contact | advertising | mirror sites