Skip to content

Instantly share code, notes, and snippets.

@akkunchoi
Created June 5, 2012 14:03
Show Gist options
  • Save akkunchoi/2875208 to your computer and use it in GitHub Desktop.
Save akkunchoi/2875208 to your computer and use it in GitHub Desktop.
sqlite php
<?php
/**
*
* $ sqlite3 hoge.db
*
* sqlite> create table hoge(id integer, name varchar(16));
* sqlite> insert into hoge values('1', 'userA');
* sqlite> .quit
*
*/
ini_set('display_errors', 1);
$db = new SQLite3('hoge.db');
try {
$db = new SQLite3('hoge.db');
} catch (Exception $e) {
print 'connection error';
print $e->getTraceAsString();
}
$id = $_GET['id'];
$result = $db->query("select * from hoge where id = '$id'");
var_dump($result);
var_dump($db->lastErrorMsg());
while($row = $result->fetchArray()){
var_dump($row);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment