1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00
Arsse/vendor/JKingWeb/NewsSync/Database.php
J. King 6ffe942f99 SQLite3 database driver in working condition
PDO stub for now; other drivers to come
2016-10-05 22:08:43 -04:00

32 lines
No EOL
690 B
PHP

<?php
declare(strict_types=1);
namespace JKingWeb\NewsSync;
class Database {
protected $drv;
public function __construct(Conf $conf) {
$driver = $conf->dbClass;
$this->drv = $driver::create($conf);
}
static public function listDrivers(): array {
$sep = \DIRECTORY_SEPARATOR;
$path = __DIR__.$sep."Db".$sep;
$classes = [];
foreach(glob($path."Driver?*.php") as $file) {
$name = basename($file, ".php");
if(substr($name,-3) != "PDO") {
$name = NS_BASE."Db\\$name";
if(class_exists($name)) {
$classes[$name] = $name::driverName();
}
}
}
return $classes;
}
public function schemaVersion(): int {
return $this->drv->schemaVersion();
}
}