Christophe Nowicki

February 4, 2006

sqlite_fetch_object for PHP4

The sqlite_fetch_object function is not implemented in the PECL extension version 1.0.3.
I’ve rewrite it 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

Filed under: Programming — Tags: — cscm @ 13:30

Comments are closed.

Powered by WordPress