本文整理汇总了PHP中Doctrine\DBAL\Connection::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getDatabase方法的具体用法?PHP Connection::getDatabase怎么用?PHP Connection::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\DBAL\Connection
的用法示例。
在下文中一共展示了Connection::getDatabase方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTableNames
private function getTableNames()
{
$tableNames = [];
foreach ($this->connection->fetchAll('SHOW TABLES') as $row) {
$tableNames[] = $row['Tables_in_' . $this->connection->getDatabase()];
}
return $tableNames;
}
示例2: getSystemInfo
/**
* Returns the system information:
* - cpu information
* - memory size
* - php version
* - php accelerator info
* - database related info.
*
* @return array
*/
public function getSystemInfo()
{
$info = ezcSystemInfo::getInstance();
$accelerator = false;
if ($info->phpAccelerator) {
$accelerator = ['name' => $info->phpAccelerator->name, 'url' => $info->phpAccelerator->url, 'enabled' => $info->phpAccelerator->isEnabled, 'versionString' => $info->phpAccelerator->versionString];
}
return ['cpuType' => $info->cpuType, 'cpuSpeed' => $info->cpuSpeed, 'cpuCount' => $info->cpuCount, 'memorySize' => $info->memorySize, 'phpVersion' => phpversion(), 'phpAccelerator' => $accelerator, 'database' => ['type' => $this->connection->getDatabasePlatform()->getName(), 'name' => $this->connection->getDatabase(), 'host' => $this->connection->getHost(), 'username' => $this->connection->getUsername()]];
}
示例3: getDsn
public function getDsn()
{
$driver = $this->connection->getDriver()->getName();
$user = $this->connection->getUsername();
$pass = $this->connection->getPassword();
$host = $this->connection->getHost();
$db = $this->connection->getDatabase();
return "{$driver}://{$user}:{$pass}@{$host}/{$db}";
}
示例4: shouldBeRun
/**
* {@inheritdoc}
*/
public function shouldBeRun()
{
$schemaManager = $this->connection->getSchemaManager();
if (!$schemaManager->tablesExist('tl_member')) {
return false;
}
$sql = $this->connection->getDatabasePlatform()->getListTableIndexesSQL('tl_member', $this->connection->getDatabase());
$index = $this->connection->fetchAssoc($sql . " AND INDEX_NAME = 'username'");
return '0' !== $index['Non_Unique'];
}
示例5: runQueriesFromFile
protected function runQueriesFromFile($file)
{
$queries = array_filter(preg_split('(;\\s*$)m', file_get_contents($file)));
if (!$this->output->isQuiet()) {
$this->output->writeln(sprintf("Executing %d queries from %s on database %s", count($queries), $file, $this->db->getDatabase()));
}
foreach ($queries as $query) {
$this->db->exec($query);
}
}
示例6: getPanel
/**
* @return string
*/
public function getPanel()
{
if (empty($this->queries)) {
return '';
}
return $this->renderStyles() . sprintf('<h1>Queries: %s %s, host: %s</h1>', count($this->queries), $this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '', sprintf('%s%s/%s', $this->connection->getHost(), ($p = $this->connection->getPort()) ? ':' . $p : '', $this->connection->getDatabase())) . '<div class="nette-inner tracy-inner nette-Doctrine2Panel">' . implode('<br>', array_filter(array($this->renderPanelCacheStatistics(), $this->renderPanelQueries()))) . '</div>';
}
示例7: get_information
/**
* Gets array database information
*
* @return array
*/
public function get_information()
{
$information = array();
$information['platform'] = $this->conn->getDatabasePlatform()->getName();
$information['database'] = $this->conn->getDatabase();
return $information;
}
示例8: listTableForeignKeys
/**
* List the foreign keys for the given table
*
* @param string $table The name of the table
* @return ForeignKeyConstraint[]
*/
public function listTableForeignKeys($table, $database = null)
{
if (is_null($database)) {
$database = $this->_conn->getDatabase();
}
$sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
$tableForeignKeys = $this->_conn->fetchAll($sql);
return $this->_getPortableTableForeignKeysList($tableForeignKeys);
}
示例9: hasOldDatabase
/**
* Checks if the database is older than version 3.2.
*
* @return bool True if the database is older than version 3.2
*/
public function hasOldDatabase()
{
if (!$this->hasTable('tl_layout')) {
return false;
}
$sql = $this->connection->getDatabasePlatform()->getListTableColumnsSQL('tl_layout', $this->connection->getDatabase());
$column = $this->connection->fetchAssoc($sql . " AND COLUMN_NAME = 'sections'");
return 'varchar(1022)' !== $column['Type'];
}
示例10: getStoreFields
/**
* Get table fields
*
* Info: $schemaManager->listTableColumns($this->tableName) doesn't work if fields are geometries!
*
* @throws \Doctrine\DBAL\DBALException
* @return array field names
*/
public function getStoreFields()
{
$schemaManager = $this->connection->getDriver()->getSchemaManager($this->connection);
$columns = array();
$sql = $schemaManager->getDatabasePlatform()->getListTableColumnsSQL($this->tableName, $this->connection->getDatabase());
foreach ($this->connection->fetchAll($sql) as $fieldInfo) {
$columns[] = $fieldInfo["field"];
}
return $columns;
}
示例11: getPanel
/**
* @return string
*/
public function getPanel()
{
if (empty($this->queries)) {
return "";
}
$s = "";
foreach ($this->queries as $query) {
$s .= $this->processQuery($query);
}
$host = sprintf('%s%s/%s', $this->connection->getHost(), ($p = $this->connection->getPort()) ? ':' . $p : '', $this->connection->getDatabase());
return $this->renderStyles() . '<h1>Queries: ' . count($this->queries) . ($this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '') . ', host: ' . $host . '</h1>' . '<div class="nette-inner tracy-inner nette-Doctrine2Panel">' . '<table><tr><th>ms</th><th>SQL Statement</th></tr>' . $s . '</table></div>';
}
示例12: metaColumns
/**
* Get meta details about a database table in a format known to ZenCart
*
* @param string $table table to get meta details for
* @return array
*/
public function metaColumns($table)
{
$platform = $this->conn->getDatabasePlatform();
$dbName = $this->conn->getDatabase();
$sql = $platform->getListTableColumnsSQL($table, $dbName);
$meta = array();
foreach ($this->conn->fetchAll($sql) as $column) {
$columnInfo = new QueryFactoryMeta($column['Type']);
$meta[$column['Field']] = $columnInfo;
}
return array_change_key_case($meta, CASE_UPPER);
}
示例13: getPanel
/**
* @return string
*/
public function getPanel()
{
if (empty($this->queries)) {
return '';
}
$connParams = $this->connection->getParams();
if ($connParams['driver'] === 'pdo_sqlite' && isset($connParams['path'])) {
$host = 'path: ' . basename($connParams['path']);
} else {
$host = sprintf('host: %s%s/%s', $this->connection->getHost(), ($p = $this->connection->getPort()) ? ':' . $p : '', $this->connection->getDatabase());
}
return $this->renderStyles() . sprintf('<h1>Queries: %s %s, %s</h1>', count($this->queries), $this->totalTime ? ', time: ' . sprintf('%0.3f', $this->totalTime * 1000) . ' ms' : '', $host) . '<div class="nette-inner tracy-inner nette-Doctrine2Panel">' . implode('<br>', array_filter([$this->renderPanelCacheStatistics(), $this->renderPanelQueries()])) . '</div>';
}
示例14: stopQuery
/**
* From SQLLogger Doctrine Interface
*/
public function stopQuery()
{
$endTime = microtime(true) - $this->start;
/**
* TODO Improve Connection name
* For now, $this->connection->getDatabase() return the name of the Database
*/
$this->registerQuery($this->query['sql'], $this->query['params'], $endTime, $this->connection->getDatabase());
/**
* This call is helpful to register queries in log file when the application is in debug/local mode
*/
$this->logger->debug($this->query['sql'] . " [Executed in " . $endTime . " secs.] ", array('params' => $this->query['params'], 'types' => $this->query['types']));
}
示例15: checkDatabase
private function checkDatabase()
{
try {
if (!$this->configuredDatabaseExists()) {
$this->output->writeln(sprintf("The configured database '%s' does not exist. Please run 'php app/console doctrine:database:create' to create the database first", $this->db->getDatabase()));
exit(self::EXIT_DATABASE_NOT_FOUND_ERROR);
}
} catch (ConnectionException $e) {
$this->output->writeln('An error occured connecting to the database:');
$this->output->writeln($e->getMessage());
$this->output->writeln('Please check the database configuration in parameters.yml');
exit(self::EXIT_GENERAL_DATABASE_ERROR);
}
}