Added SQLite3 installed check [Cache/Datastore] (#652)

This commit is contained in:
Roman Kelesidis 2023-03-26 14:45:50 +07:00 committed by GitHub
commit 49ac3503c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -36,6 +36,10 @@ class Sqlite extends Common
public function __construct($cfg, $prefix = null)
{
if (!$this->is_installed()) {
die('Error: SQLite3 extension not installed');
}
$this->cfg = array_merge($this->cfg, $cfg);
$this->db = new SqliteCommon($this->cfg);
$this->prefix = $prefix;
@ -110,4 +114,9 @@ class Sqlite extends Common
$result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time");
return $result ? $this->db->changes() : 0;
}
public function is_installed()
{
return class_exists('SQLite3');
}
}

View file

@ -35,6 +35,10 @@ class Sqlite extends Common
public function __construct($cfg, $prefix = null)
{
if (!$this->is_installed()) {
die('Error: SQLite3 extension not installed');
}
$this->cfg = array_merge($this->cfg, $cfg);
$this->db = new SqliteCommon($this->cfg);
$this->prefix = $prefix;
@ -77,4 +81,9 @@ class Sqlite extends Common
}
$this->db->debug('stop');
}
public function is_installed()
{
return class_exists('SQLite3');
}
}