summaryrefslogtreecommitdiff
path: root/db.php
blob: e5c924c68e9c7079a400f7421d7fd72d126de82c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
class Db {
	private static $instance;
	private $dbh;

	private function __construct() {
		try {
			$this->dbh = new PDO('sqlite:' . SCRATCH_DB);
		} catch (Exception $e) {
			die("Unable to initialize database driver (SQLite): $e");
		}
		//$this->dbh->busyTimeout(30*1000);
		$this->dbh->query('PRAGMA journal_mode = wal;');
	}

	public static function get() {
		if (self::$instance == null)
			self::$instance = new self();

		return self::$instance->dbh;
	}

};

?>