db.php 416 B

123456789101112131415161718192021
  1. <?php
  2. class Db {
  3. private static $instance;
  4. private $dbh;
  5. private function __construct() {
  6. $this->dbh = new SQLite3((strpos(SCRATCH_DB,"/") == 0 ? "" : __DIR__ . "/") . SCRATCH_DB);
  7. $this->dbh->busyTimeout(30*1000);
  8. $this->dbh->exec('PRAGMA journal_mode = wal;');
  9. }
  10. public static function get() {
  11. if (self::$instance == null)
  12. self::$instance = new self();
  13. return self::$instance->dbh;
  14. }
  15. };
  16. ?>