public function run() { if (count($this->arguments) < 2) { $this->error("to few arguments."); $this->usage(); exit; } $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $directory = $this->defineMigrationDirectory(); $connectionName = $this->connectionName = $this->getConnectionName(); $this->stmt = Sabel_Db::createStatement($connectionName); $this->metadata = Sabel_Db::createMetadata($connectionName); // @todo //if ($this->arguments[1] === "export") { // $this->export(); // self::$execFinalize = false; //} else { $tblName = $this->arguments[1]; $this->currentVersion = $this->getCurrentVersion(); if (in_array($tblName, array("-v", "--version"), true)) { $this->success("CURRENT VERSION: " . $this->currentVersion); exit; } else { $this->execMigration(); } //} }
public function testInitialize() { Sabel_Db_Config::initialize(new TestDatabaseConfig()); $config = Sabel_Db_Config::get("configtest"); $this->assertEquals("localhost", $config["host"]); $this->assertEquals("mydb", $config["database"]); }
public function run() { if (count($this->arguments) < 2) { $this->error("to few arguments."); $this->usage(); exit; } if (!defined('_LEGACY_PREVENT_LOAD_CORE_')) { define('_LEGACY_PREVENT_LOAD_CORE_', 'suin.asia'); require_once dirname(dirname(RUN_BASE)) . '/mainfile.php'; } $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $directory = $this->defineMigrationDirectory(); $connectionName = $this->connectionName = $this->getConnectionName(); $this->stmt = Sabel_Db::createStatement($connectionName); $this->metadata = Sabel_Db::createMetadata($connectionName); // @todo //if ($this->arguments[1] === "export") { // $this->export(); // self::$execFinalize = false; //} else { $tblName = $this->arguments[1]; $this->currentVersion = $this->getCurrentVersion(); if (in_array($tblName, array("-v", "--version"), true)) { $this->success("CURRENT VERSION: " . $this->currentVersion); exit; } else { $this->execMigration(); } //} }
public function run() { clearstatcache(); $this->checkInputs(); $outputDir = RUN_BASE . DS . LIB_DIR_NAME . DS . "schema"; $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); $isAll = false; $tables = $this->getOutputTables(); if (isset($tables[0]) && strtolower($tables[0]) === "all") { $isAll = count($tables) === 1; } $tList = new TableListWriter($outputDir); foreach (Sabel_Db_Config::get() as $connectionName => $params) { Sabel_Db_Config::add($connectionName, $params); $db = Sabel_Db::createMetadata($connectionName); foreach ($db->getTableList() as $tblName) { if ($isAll || in_array($tblName, $tables, true)) { $writer = new Sabel_Db_Metadata_FileWriter($outputDir); $writer->write($db->getTable($tblName)); $this->success("generate Schema 'Schema_" . convert_to_modelname($tblName) . "'"); } $tList->add($connectionName, $tblName); } if (Sabel_Console::hasOption("l", $this->arguments)) { $tList->write($connectionName); } } }
public function execute(Sabel_Bus $bus) { Sabel_Db_Config::initialize($bus->getConfig("database")); if (!is_cli() && ($session = $bus->get("session")) !== null) { $session->start(); l("START SESSION: " . $session->getName() . "=" . $session->getId()); } // default page title. if ($response = $bus->get("response")) { $response->setResponse("pageTitle", "Sabel"); } }
public function execute($bus) { Sabel_Db_Config::initialize($bus->getConfig("database")); Sabel::fileUsing(RUN_BASE . DS . LIB_DIR_NAME . DS . "db" . DS . "utility.php", true); if (!defined("SBL_BATCH")) { // start session. $session = $bus->get("session"); $session->start(); l("START SESSION: " . $session->getName() . "=" . $session->getId()); } // default page title. $bus->get("response")->setResponse("pageTitle", "Phwittr"); // $request = $bus->get("request"); // if ($request->isPost()) $this->trim($request); }
public function run() { Sabel_Db_Config::initialize(new Config_Database()); $runner = Sabel_Test_Runner::create(); $runner->setClassPrefix("Unit_"); $testsDir = RUN_BASE . DS . "tests" . DS . "unit"; if (count($this->arguments) === 0) { foreach (scandir($testsDir) as $file) { if (preg_match("/^[A-Z].+\\.php\$/", $file)) { $testName = str_replace(".php", "", $file); $runner->start($testName, $testsDir . DS . $file); } } } else { $testName = $this->arguments[0]; $runner->start($testName, $testsDir . DS . $testName . ".php"); } }
public function run() { if (count($this->arguments) < 2) { $this->usage(); exit; } $method = $this->getFixtureMethod(); $this->defineEnvironment($this->arguments[0]); Sabel_Db_Config::initialize(new Config_Database()); if (Sabel_Console::hasOption("export", $this->arguments)) { unset($this->arguments[array_search("--export", $this->arguments, true)]); return $this->export("fixture"); } elseif (Sabel_Console::hasOption("export-csv", $this->arguments)) { $dir = Sabel_Console::getOption("export-csv", $this->arguments); if ($dir === null) { $dir = RUN_BASE . DS . "data"; } return $this->export("csv", $dir); } $fixtureName = $this->arguments[1]; if ($fixtureName === "all") { foreach (scandir(FIXTURE_DIR) as $item) { if ($item === "." || $item === "..") { continue; } Sabel::fileUsing(FIXTURE_DIR . DS . $item, true); $className = "Fixture_" . substr($item, 0, strlen($item) - 4); $instance = new $className(); $instance->initialize(); $instance->{$method}(); } } else { $filePath = FIXTURE_DIR . DS . $fixtureName . ".php"; if (Sabel::fileUsing($filePath, true)) { $className = "Fixture_" . $fixtureName; $instance = new $className(); $instance->initialize(); $instance->{$method}(); $this->success(ucfirst($method) . " " . $fixtureName); } else { $this->error("no such fixture file. '{$filePath}'"); } } }
public function __construct() { Sabel_Db_Config::initialize(new Config_Database()); }