FileDB 클래스 추가

This commit is contained in:
2018-07-23 22:37:30 +09:00
parent 7b0cffcf30
commit 792e9717b2
3 changed files with 32 additions and 0 deletions
+1
View File
@@ -45,3 +45,4 @@ test.php
phpinfo.php
vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/*
*.sqlite3
+12
View File
@@ -0,0 +1,12 @@
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS `err_log` (
`id` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
`date` TEXT NOT NULL,
`err` TEXT NOT NULL,
`errstr` TEXT NOT NULL,
`trace` TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS `date` ON `err_log` (
`date` DESC
);
COMMIT;
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace sammo;
//SQLite + catfan\Medoo
use \Medoo\Medoo;
class FileDB{
public static function DB(string $path, ?string $schemaPath = null) : Medoo{
//Note: reference count 적용. MySQL의 것과 다르게 동작함.
$db = new Medoo([
'database_type' => 'sqlite',
'database_file' => $path
]);
if($schemaPath){
$db->query(\file_get_contents($schemaPath));
}
return $db;
}
}