Skip to content

Commit

Permalink
Added SQLite3 installed check (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
belomaxorka committed Mar 31, 2023
1 parent 5af4f7f commit ebe3e62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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');
}
}

0 comments on commit ebe3e62

Please sign in to comment.