Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SQLite3 installed check #92

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions library/includes/cache/sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class cache_sqlite extends cache_common

function cache_sqlite ($cfg, $prefix = null)
{
if (!$this->is_installed())
{
die('Error: SQLite3 extension not installed');
}

$this->cfg = array_merge($this->cfg, $cfg);
$this->db = new sqlite_common($this->cfg);
$this->prefix = $prefix;
Expand Down Expand Up @@ -107,6 +112,11 @@ function gc ($expire_time = TIMENOW)
$result = $this->db->query("DELETE FROM ". $this->cfg['table_name'] ." WHERE cache_expire_time < $expire_time");
return ($result) ? $this->db->changes() : 0;
}

function is_installed ()
{
return class_exists('SQLite3');
}
}

class sqlite_common extends cache_common
Expand Down
10 changes: 10 additions & 0 deletions library/includes/datastore/sqlite.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class datastore_sqlite extends datastore_common

function datastore_sqlite ($cfg, $prefix = null)
{
if (!$this->is_installed())
{
die('Error: SQLite3 extension not installed');
}

$this->cfg = array_merge($this->cfg, $cfg);
$this->db = new sqlite_common($this->cfg);
$this->prefix = $prefix;
Expand Down Expand Up @@ -63,4 +68,9 @@ function _fetch_from_store ()
}
$this->db->debug('stop');
}

function is_installed ()
{
return class_exists('SQLite3');
}
}