getDatabaseInstance(); } $this->db = self::$dbInstance; } public function getDatabaseInstance() { $db = new \PicoDb\Database(array( 'driver' => 'sqlite', 'filename' => self::DB_FILENAME )); if ($db->schema()->check(self::DB_VERSION)) { return $db; } else { die('Unable to migrate database schema!'); } } // Generate a random token from /dev/urandom or with uniqid() public static function generateToken() { if (ini_get('open_basedir') === '') { $token = file_get_contents('/dev/urandom', false, null, 0, 30); } else { $token = uniqid(mt_rand(), true); } return hash('crc32b', $token); } }