<?php
class MyDB extends SQLite3 {
function __construct($dbname) {
$this->open($dbname);
}
}
if (isset($argv[1])) {
$name = $argv[1];
$db = new MyDB($name);
if(!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql = "drop table Issues";
$ret = $db->exec($sql);
$sql =<<<EOF
CREATE TABLE Issues
(ID INT PRIMARY KEY NOT NULL,
Subject TEXT NOT NULL,
Date TEXT NOT NULL,
Link TEXT NOT NULL
);
EOF;
$ret = $db->exec($sql);
if(!$ret){
echo $db->lastErrorMsg();
} else {
echo "Table created successfully\n";
}
$db->close();
} else {
echo "Please enter a DB name to use.\n";
}
?>