PHP Sqlite

Newest database extension with arguably the fastest interface between the database & PHP.

  • Bundled with PHP 5 (including library)
  • Fast and easy interface to 'flatfiles'
  • Implements most of SQL92
  • Supports both OO and procedural API
  • No daemon required
  • Enabled by default
  • Can use PHP to extend SQL language

Sqlite OO Interface

<?php

$db = new SQLite3('files.sqlite');

$db->exec('CREATE TABLE files (id INTEGER PRIMARY KEY, filename TEXT, content BLOB);');

$statement = $db->prepare('INSERT INTO files (filename, content) VALUES (?, ?);');
$statement->bindValue('filename', 'Archive.zip');
$statement->bindValue('content', file_get_contents('Archive.zip'));
$result = $statement->execute();


// Either FetchArray $result or use openBlog below.

die(var_dump($result->fetchArray()));


/*
Comment above die function to fetch using openBlog

$fp = $db->openBlob('files', 'content', $id);

while (!feof($fp))
{
    echo fgets($fp);
}

fclose($fp);
*/

?>

Loading ...

Related Results :

  1. PHP Sqlite
Note :
  • Related Posts are generally User Blog posts.
  • or Other tutorials from other networks of w3clan.com.
  • Any registered user can create related posts based on search term tags.

About the Author