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.
mysqli_result クラス
(PHP 5)
導入
データベースへのクエリにより得られた結果セットを表します。
変更履歴
| バージョン | 説明 |
|---|---|
| 5.4.0 | Iterator に対応するため、 mysqli_result は Traversable を実装するようになりました。 |
クラス概要
mysqli_result
{
/* プロパティ */
int $current_field
;
int $field_count;
array $lengths;
int $num_rows;
/* メソッド */
}目次
- mysqli_result::$current_field — 結果ポインタにおける現在のフィールドオフセットを取得する
- mysqli_result::data_seek — 結果の任意の行にポインタを移動する
- mysqli_result::fetch_all — 結果のすべての行を連想配列・数値添字配列あるいはその両方の形式で取得する
- mysqli_result::fetch_array — 結果の行を連想配列・数値添字配列あるいはその両方の形式で取得する
- mysqli_result::fetch_assoc — 結果の行を連想配列で取得する
- mysqli_result::fetch_field_direct — 単一のフィールドのメタデータを取得する
- mysqli_result::fetch_field — 結果セットの次のフィールドを返す
- mysqli_result::fetch_fields — 結果セットのフィールド情報をオブジェクトの配列で返す
- mysqli_result::fetch_object — 結果セットの現在の行をオブジェクトとして返す
- mysqli_result::fetch_row — 結果の行を数値添字配列で取得する
- mysqli_result::$field_count — 結果のフィールド数を取得する
- mysqli_result::field_seek — 結果ポインタを、指定したフィールドオフセットに設定する
- mysqli_result::free — 結果に関連付けられたメモリを開放する
- mysqli_result::$lengths — 結果セットにおける現在の行のカラムの長さを返す
- mysqli_result::$num_rows — 結果の行数を取得する
sinisaculic at gmail dot com
21-Oct-2010 01:58
Anonymous
18-Apr-2010 11:39
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 02:47
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;
}
}
?>
