PHP Doku:: Holt sich die nächste Reihe des Ergebnisses und gibt diese als Objekt zurück - function.sqlite-fetch-object.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzDatenbankerweiterungenAnbieterspezifische DatenbankerweiterungenSQLiteSQLite Funktionensqlite_fetch_object -- SQLiteResult->fetchObject -- SQLiteUnbuffered->fetchObject

Ein Service von Reinhard Neidl - Webprogrammierung.

SQLite Funktionen

<<sqlite_fetch_column_types -- SQLiteDatabase->fetchColumnTypes

sqlite_fetch_single -- SQLiteResult->fetchSingle -- SQLiteUnbuffered->fetchSingle>>

sqlite_fetch_object

SQLiteResult->fetchObject

SQLiteUnbuffered->fetchObject

(PHP 5)

sqlite_fetch_object -- SQLiteResult->fetchObject -- SQLiteUnbuffered->fetchObjectHolt sich die nächste Reihe des Ergebnisses und gibt diese als Objekt zurück

Beschreibung

object sqlite_fetch_object ( resource $result [, string $class_name [, array $ctor_params [, bool $decode_binary = true ]]] )

Objektorientierter Stil (Methode):

object 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 ]]] )
Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.


4 BenutzerBeiträge:
- Beiträge aktualisieren...
florian at phpws dot org
12.08.2006 19:13
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;
}
vbwebprofi at gmx dot de
12.03.2006 4:39
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
cscm at meuh dot dyndns dot org
4.02.2006 13:35
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
Benjamin
22.09.2004 7:34
This function is not implemented in the PECL extension version 1.0.3  http://pecl.php.net/package/SQLite/1.0.3



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)