mercredi 24 février 2016

What is the difference between PHP SQLite3 class and sqlite_open?

I have been trying to create a database in SQLite in PHP like this:

$db = new SQLite3("users.db");

– but I got this error:

Fatal error: Class 'SQLite3' not found

– although, this works:

if ($db = sqlite_open('d', 0666, $e)) { 
    sqlite_query($db, 'CREATE TABLE foo (bar varchar(10))');
    sqlite_query($db, "INSERT INTO foo VALUES ('fnord')");
    $result = sqlite_query($db, 'select bar from foo');
    var_dump(sqlite_fetch_array($result)); 
    echo($result);
} else {
    die($sqliteerror);
}

– what's the difference? I would rather use the class, but why can't I?

Aucun commentaire:

Enregistrer un commentaire