public function init(OutputInterface $output = null, $dbPath = null) { $this->setDefaultCommand('run'); if ($output === null) { $output = new ConsoleOutput(); } $this->output = new ConsoleStyle(new ArgvInput(), $output); $this->folder = dirname(dirname(__FILE__)); chdir($this->folder); if ($dbPath === null) { $dbPath = $this->folder . '/db.sqlite'; } DBA::connect('sqlite:' . $dbPath, '', ''); $this->settings = new Settings($this); $migration = new Migration($this); $migration->run(); // Prevent the previous command from being executed in case anything fails later on $this->batchPath = $this->folder . DIRECTORY_SEPARATOR . 'cli-launch.temp.bat'; file_put_contents($this->batchPath, ''); }
/** * Returns false when there are no tables at all * * @return bool */ private function hasTables() { $sql = 'SELECT COUNT(*) FROM sqlite_master'; $count = (int) DBA::execute($sql)->fetchColumn(); return $count !== 0; }