- PHP 手册
- 函数参考
- 数据库扩展
- 针对各数据库系统对应的扩展
- SQLite
- SQLite 函数
sqlite_fetch_object
SQLiteResult::fetchObject
SQLiteUnbuffered::fetchObject
(PHP 5 < 5.4.0)
sqlite_fetch_object -- SQLiteResult::fetchObject -- SQLiteUnbuffered::fetchObject — Fetches the next row from a result set as an object
说明
sqlite_fetch_object ( resource$result
[, string $class_name
[, array $ctor_params
[, bool $decode_binary
= TRUE
]]] ) : object
面向对象风格 (method):
SQLiteResult::fetchObject ([ string$class_name
[, array $ctor_params
[, bool $decode_binary
= TRUE
]]] ) : object
SQLiteUnbuffered::fetchObject
([ string $class_name
[, array $ctor_params
[, bool $decode_binary
= TRUE
]]] ) : object
Warning本函数还未编写文档,仅有参数列表。
User Contributed Notes 4 notes
up down 1 florian at phpws dot org ¶12 years ago
Here is the function from "cscm at meuh dot dyndns dot org" rewriten.
I think it will work better when really assigning the values ;-)
Also I'd replace the empty "bidon" class by stdClass wich is such an empty class and is provided by default.
// Fetch resultset as an object
function sqlite_fetch_object(&$resource){
$arr = sqlite_fetch_array($resource);
$obj = new stdClass();
foreach ($arr as $key => $value) {
# Check is valid $T_VARIABLE
if (ereg(\"[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\", $key)) {
$obj->$key = $value;
}
}
return $obj;
}
up
down
0
vbwebprofi at gmx dot de ¶13 years ago
Here a light workaround for PHP 4.x which I use in my DBAccess class :
<?
function sqlite_fetch_object(&$result) {
$vO = sqlite_fetch_array($result, SQLITE_ASSOC);
if($vO) {
$vO = (object) $vO;
}
return $vO;
}
?>
HTH Holger
up
down
0
cscm at meuh dot dyndns dot org ¶13 years ago
As the sqlite_fetch_object function is not implemented in the PECL extension version 1.0.3.
I官方地址:https://www.php.net/manual/en/function.sqlite-fetch-object.php