本文整理汇总了PHP中base::get_dbname方法的典型用法代码示例。如果您正苦于以下问题:PHP base::get_dbname方法的具体用法?PHP base::get_dbname怎么用?PHP base::get_dbname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base::get_dbname方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dump_base
protected function dump_base(base $base, InputInterface $input, OutputInterface $output)
{
$date_obj = new DateTime();
$filename = sprintf('%s%s_%s.sql', p4string::addEndSlash($input->getArgument('directory')), $base->get_dbname(), $date_obj->format('Y_m_d_H_i_s'));
$command = sprintf('mysqldump %s %s %s %s %s %s --default-character-set=utf8', '--host=' . escapeshellarg($base->get_host()), '--port=' . escapeshellarg($base->get_port()), '--user=' . escapeshellarg($base->get_user()), '--password=' . escapeshellarg($base->get_passwd()), '--databases', escapeshellarg($base->get_dbname()));
if ($input->getOption('gzip')) {
$filename .= '.gz';
$command .= ' | gzip -9';
} elseif ($input->getOption('bzip')) {
$filename .= '.bz2';
$command .= ' | bzip2 -9';
}
$output->write(sprintf('Generating <info>%s</info> ... ', $filename));
$command .= ' > ' . escapeshellarg($filename);
$process = new Process($command);
$process->setTimeout((int) $input->getOption('timeout'));
$process->run();
if (!$process->isSuccessful()) {
$output->writeln('<error>Failed</error>');
return 1;
}
if (file_exists($filename) && filesize($filename) > 0) {
$output->writeln('OK');
return 0;
} else {
$output->writeln('<error>Failed</error>');
return 1;
}
}
示例2: upgradeDatabase
public function upgradeDatabase(\base $base, $applyPatches)
{
$recommends = [];
$allTables = [];
$schema = $base->get_schema();
foreach ($schema->tables->table as $table) {
$allTables[(string) $table['name']] = $table;
}
$foundTables = $this->connection->fetchAll("SHOW TABLE STATUS");
foreach ($foundTables as $foundTable) {
$tableName = $foundTable["Name"];
if (isset($allTables[$tableName])) {
$engine = strtolower(trim($allTables[$tableName]->engine));
$ref_engine = strtolower($foundTable['Engine']);
if ($engine != $ref_engine && in_array($engine, ['innodb', 'myisam'])) {
$recommends = $this->alterTableEngine($tableName, $engine, $recommends);
}
$ret = $this->upgradeTable($allTables[$tableName]);
$recommends = array_merge($recommends, $ret);
unset($allTables[$tableName]);
} elseif (!in_array($tableName, self::$ormTables)) {
$recommends[] = ['message' => 'Une table pourrait etre supprime', 'sql' => 'DROP TABLE ' . $base->get_dbname() . '.`' . $tableName . '`;'];
}
}
foreach ($allTables as $tableName => $table) {
$this->createTable($table);
}
$current_version = $base->get_version();
if ($applyPatches) {
$this->applyPatches($base, $current_version, $this->app['phraseanet.version']->getNumber(), false, $this->app);
}
return $recommends;
}