<?php
    class MyDB extends SQLite3 {
        function __construct($dbname) {
            $this->open($dbname);
        }
   }

   // Get the DB filename 
if (isset($argv[1])) {
    $name = $argv[1];
    // Create an instance of this DB thus opening it.
    $db = new MyDB($name);
    // Error if it did not open OK
    if(!$db) {
        echo $db->lastErrorMsg();
    } else {
        echo "Opened database successfully\n";
    }

    // Drop the table 
    $sql = "drop table Issues";
    $ret = $db->exec($sql);

    // And a query to recreate the specific table for Issues
    $sql =<<<EOF
      CREATE TABLE Issues
      (ID          INT PRIMARY KEY    NOT NULL,
      Subject      TEXT               NOT NULL,
      Date         TEXT               NOT NULL,
      Link         TEXT		      NOT NULL
      );
EOF;
    // Execute the query
    $ret = $db->exec($sql);
    // Error if it was not created OK.
    if(!$ret){
        echo $db->lastErrorMsg();
    } else {
        echo "Table created successfully\n";
    }
    $db->close();
    // Error if DB file not supplied.
} else {
    echo "Please enter a DB name to use.\n";
}
?>