2017-03-31 17:24:00 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\Arsse\Test\Database;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-07-17 11:47:57 +00:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-03-31 17:24:00 +00:00
|
|
|
use JKingWeb\Arsse\Db\SQLite3\Driver;
|
|
|
|
|
|
|
|
trait DriverSQLite3 {
|
2017-08-29 14:50:31 +00:00
|
|
|
public function setUpDriver() {
|
|
|
|
if (!extension_loaded("sqlite3")) {
|
2017-05-22 14:02:36 +00:00
|
|
|
$this->markTestSkipped("SQLite extension not loaded");
|
|
|
|
}
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$conf->dbSQLite3File = ":memory:";
|
2017-10-19 19:32:18 +00:00
|
|
|
$this->drv = new Driver();
|
2017-03-31 17:24:00 +00:00
|
|
|
}
|
2017-05-11 01:21:23 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function nextID(string $table): int {
|
2017-05-11 01:21:23 +00:00
|
|
|
return $this->drv->query("SELECT (case when max(id) then max(id) else 0 end)+1 from $table")->getValue();
|
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|