sqlite_fetch_object
(PHP 5)
sqlite_fetch_object — Выбирает следующую запись из результата запроса и возвращает объект
Описание
object sqlite_fetch_object
( resource $result
[, string $class_name
[, array $ctor_params
[, bool $decode_binary
]]] )
Внимание
К настоящему времени эта функция еще не была документирована; для ознакомления доступен только список аргументов.
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- SQLite
- sqlite_array_query
- sqlite_busy_timeout
- sqlite_changes
- sqlite_close
- sqlite_column
- sqlite_create_aggregate
- sqlite_create_function
- sqlite_current
- sqlite_error_string
- sqlite_escape_string
- sqlite_exec
- sqlite_factory
- sqlite_fetch_all
- sqlite_fetch_array
- sqlite_fetch_column_types
- sqlite_fetch_object
- sqlite_fetch_single
- sqlite_fetch_string
- sqlite_field_name
- sqlite_has_more
- sqlite_has_prev
- sqlite_key
- sqlite_last_error
- sqlite_last_insert_rowid
- sqlite_libencoding
- sqlite_libversion
- sqlite_next
- sqlite_num_fields
- sqlite_num_rows
- sqlite_open
- sqlite_popen
- sqlite_prev
- sqlite_query
- sqlite_rewind
- sqlite_seek
- sqlite_single_query
- sqlite_udf_decode_binary
- sqlite_udf_encode_binary
- sqlite_unbuffered_query
- sqlite_valid
Коментарии
This function is not implemented in the PECL extension version 1.0.3 http://pecl.php.net/package/SQLite/1.0.3
As the sqlite_fetch_object function is not implemented in the PECL extension version 1.0.3.
I?ve rewrite the sqlite_fetch_object in PHP :
// An empty class
class bidon {
}
// Fetch resultset as an object
function sqlite_fetch_object(&$resource){
$arr = sqlite_fetch_array($resource);
$obj = new bidon();
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;
}
}
return $obj;
}
Voila
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
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;
}