<?php
    /**
     * DB helper file.
     *
     * Provides a helper to perform database operations.
     *
     * @category Helper.
     */

    /**
     * Require dependent files if not present.
     */
    require_once(PATH::HELPER . "Helper.php");

    /**
     * Database helper.
     *
     * Contains database utilities to connect.
     *
     * @category Helper.
     */
    final class DB extends Helper{

        /**
         * Creates a database connection using the data in the config files.
         * 
         * @return resource Connection to the database.
         */
        public static function start(){
            /*class SQLite extends SQLite3 {
                function __construct($file) {
                    $this->open($file);
                }
            }*/
            $db = new SQLite3(PATH::DB_KEY);
            if(!$db) {
                error_log($db->lastErrorMsg());
            }
            else {
                $db->query("attach '" . PATH::DB_DATA . "' as data");
                return $db;
            }
        }
    }
?>

