本文整理匯總了PHP中KConfig::getDatabaseInfo方法的典型用法代碼示例。如果您正苦於以下問題:PHP KConfig::getDatabaseInfo方法的具體用法?PHP KConfig::getDatabaseInfo怎麽用?PHP KConfig::getDatabaseInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類KConfig
的用法示例。
在下文中一共展示了KConfig::getDatabaseInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: InputArgument
$console->register('db:schema:dump')->setDescription('Dumps the schema for a component into its schema.sql file')->setDefinition(array(new InputArgument('component', InputArgument::IS_ARRAY, 'Name of the components')))->setCode(function (InputInterface $input, OutputInterface $output) use($console) {
$component = ask_for_component($input, $output, $console);
$migrators = new Migrators($console, $component, false);
$migrators->setOutput($output);
foreach ($migrators as $migrator) {
$migrator->createSchema();
$migrator->write();
$output->writeLn('<info>Dump database schema for com_' . $migrator->getComponent() . '</info>');
}
});
if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
$console->register('db:dump')->setDescription('Dump data to a sql file')->setDefinition(array(new InputArgument('file', InputArgument::OPTIONAL, 'The output file'), new InputOption('replace-prefix', null, InputOption::VALUE_NONE)))->setCode(function (InputInterface $input, OutputInterface $output) use($console) {
$file = $input->getArgument('file');
$console->loadFramework();
$config = new Config(WWW_ROOT);
$config = new \KConfig($config->getDatabaseInfo());
$cmd = "mysqldump --add-drop-table --extended-insert=FALSE --add-locks --skip-comments -u {$config->user} -p{$config->password} -h{$config->host} -P{$config->port} {$config->name}";
if ($input->getOption('replace-prefix')) {
$cmd .= " | sed -e 's/`{$config->prefix}/`#__/'";
}
if ($file) {
@mkdir(dirname($file), 0755, true);
system("{$cmd} > {$file}");
} else {
passthru($cmd);
}
});
}
$console->register('db:load')->setDescription('Load data from a sql file into the database')->setDefinition(array(new InputArgument('file', InputArgument::REQUIRED, 'The output file')))->setCode(function (InputInterface $input, OutputInterface $output) use($console) {
$file = realpath($input->getArgument('file'));
if (!file_exists($file)) {