<?php
session_start();
include_once 'logging.php';

class Database2 {
    private $db_name;
    private $conn;

    public function __construct() {
                $this->db_name = './db/calendar.db';
        $this->conn = null;
        _log('db2 name: ./db/calendar.db');
    }
    public function connect() {
        try {
            if ($this->conn == null) {
                $this->conn = new PDO('sqlite:' . $this->db_name);
                $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
                _log('db2: Connected');
            }
            return $this->conn;
        } catch (PDOException $e) {
            _log("Error!: " . $e->getMessage());
            print "Error!: " . $e->getMessage() . "<br/>";
        }
    }
}
?>