diff --git a/src/wp_db_light.php b/src/wp_db_light.php index 10fa414..ef236af 100644 --- a/src/wp_db_light.php +++ b/src/wp_db_light.php @@ -5,10 +5,15 @@ namespace WP_DB; class WP_DB_LIGHT extends WP_DB { public $dbName; + public $path = false; function connect() { - $databaseFile = '/sql/'.$this->dbName.'.db'; + $path = '/sql/'; + if ($this->path) { + $path .= $this->path . "/"; + } + $databaseFile = $path . $this->dbName . '.db'; $pdo = new \PDO("sqlite:$databaseFile"); // Set the error mode to exception @@ -17,5 +22,10 @@ class WP_DB_LIGHT extends WP_DB return $pdo; } - + function createPathIfnotExists($folderPath) + { + if (!file_exists($folderPath)) { + mkdir($folderPath, 0777, true); + } + } }