当前位置: 首页>>代码示例>>PHP>>正文


PHP Connection::getHost方法代码示例

本文整理汇总了PHP中Doctrine\DBAL\Connection::getHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::getHost方法的具体用法?PHP Connection::getHost怎么用?PHP Connection::getHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\DBAL\Connection的用法示例。


在下文中一共展示了Connection::getHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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}";
 }
开发者ID:jfortunato,项目名称:quickbooks-desktop-bundle,代码行数:9,代码来源:Config.php

示例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()]];
 }
开发者ID:emodric,项目名称:PlatformUIBundle,代码行数:19,代码来源:SystemInfoHelper.php

示例3: 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>';
 }
开发者ID:richard-ejem,项目名称:Doctrine,代码行数:10,代码来源:Panel.php

示例4: createConfigFile

 private function createConfigFile(OutputInterface $output)
 {
     $template = file_get_contents(__DIR__ . '/config.php.bak');
     $result = str_replace(array('{{host}}', '{{database}}', '{{user}}', '{{password}}'), array($this->dbConnection->getHost(), $this->dbName, $this->dbConnection->getUsername(), $this->dbConnection->getPassword()), $template);
     $filename = __DIR__ . '/../../../../site/config.php';
     file_put_contents($filename, $result);
     chmod($filename, 0644);
     $output->writeln('Create config file success with chmod 644');
 }
开发者ID:gusdecool,项目名称:bunga-wire,代码行数:9,代码来源:InstallRun.php

示例5: 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>';
 }
开发者ID:pt24,项目名称:doctrine,代码行数:15,代码来源:Panel.php

示例6: 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>';
 }
开发者ID:LidskaSila,项目名称:Doctrine,代码行数:16,代码来源:Panel.php

示例7: getHost

 public function getHost()
 {
     if (empty($this->usedParams)) {
         return parent::getHost();
     } else {
         return isset($this->usedParams['host']) ? $this->usedParams['host'] : null;
     }
 }
开发者ID:kirillsablin,项目名称:doctrine-failover,代码行数:8,代码来源:MasterMasterFailoverConnection.php

示例8: create

 public static function create(Application $app, Connection $connection, \SplFileInfo $data_template)
 {
     if (!file_exists($data_template->getRealPath())) {
         throw new \InvalidArgumentException($data_template->getRealPath() . " does not exist");
     }
     $sql = 'SELECT sbas_id
         FROM sbas
         WHERE host = :host AND port = :port AND dbname = :dbname
           AND user = :user AND pwd = :password';
     $host = $connection->getHost();
     $port = $connection->getPort();
     $dbname = $connection->getDatabase();
     $user = $connection->getUsername();
     $password = $connection->getPassword();
     $params = [':host' => $host, ':port' => $port, ':dbname' => $dbname, ':user' => $user, ':password' => $password];
     $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute($params);
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if ($row) {
         return $app['phraseanet.appbox']->get_databox((int) $row['sbas_id']);
     }
     try {
         $sql = 'CREATE DATABASE `' . $dbname . '`
           CHARACTER SET utf8 COLLATE utf8_unicode_ci';
         $stmt = $connection->prepare($sql);
         $stmt->execute();
         $stmt->closeCursor();
     } catch (\Exception $e) {
     }
     $sql = 'USE `' . $dbname . '`';
     $stmt = $connection->prepare($sql);
     $stmt->execute();
     $stmt->closeCursor();
     $sql = 'SELECT MAX(ord) as ord FROM sbas';
     $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute();
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     if ($row) {
         $ord = $row['ord'] + 1;
     }
     $sql = 'INSERT INTO sbas (sbas_id, ord, host, port, dbname, sqlengine, user, pwd)
           VALUES (null, :ord, :host, :port, :dbname, "MYSQL", :user, :password)';
     $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);
     $stmt->execute([':ord' => $ord, ':host' => $host, ':port' => $port, ':dbname' => $dbname, ':user' => $user, ':password' => $password]);
     $stmt->closeCursor();
     $sbas_id = (int) $app['phraseanet.appbox']->get_connection()->lastInsertId();
     $app['phraseanet.appbox']->delete_data_from_cache(appbox::CACHE_LIST_BASES);
     $databox = $app['phraseanet.appbox']->get_databox($sbas_id);
     $databox->insert_datas();
     $databox->setNewStructure($data_template, $app['conf']->get(['main', 'storage', 'subdefs', 'default-dir']));
     return $databox;
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:54,代码来源:databox.php

示例9: formatDSN

 /**
  * @todo make the mysql bit dynamic
  * @param Connection $connection
  */
 private function formatDSN(Connection $connection)
 {
     $driver_name = $this->getPropelDriverName($connection->getDriver());
     if ($connection->getDriver()->getName() == 'pdo_sqlite') {
         return sprintf('%s://hack.nl/%s', $driver_name, $connection->getDatabase());
     }
     $params = $connection->getParams();
     return sprintf('%s://%s:%s@%s%s/%s?encoding=%s', $driver_name, $connection->getUsername(), $connection->getPassword(), $connection->getHost(), $connection->getPort() ? ':' . $connection->getPort() : '', $connection->getDatabase(), isset($params['charset']) ? $params['charset'] : 'utf8');
 }
开发者ID:eddypouw,项目名称:hnDependencyInjectionPlugin,代码行数:13,代码来源:HnDatabaseConfigHandler.php

示例10: getHost

 /**
  * {@inheritdoc}
  */
 public function getHost()
 {
     $params = $this->getParams();
     return isset($params['host']) ? $params['host'] : parent::getHost();
 }
开发者ID:betes-curieuses-design,项目名称:ElieJosiePhotographie,代码行数:8,代码来源:PoolingShardConnection.php

示例11: collect

 /**
  * Collects information about the database eZ Platform is using.
  *  - type
  *  - name
  *  - host
  *  - username
  *
  * @return Value\DatabaseSystemInfo
  */
 public function collect()
 {
     return new Value\DatabaseSystemInfo(['type' => $this->connection->getDatabasePlatform()->getName(), 'name' => $this->connection->getDatabase(), 'host' => $this->connection->getHost(), 'username' => $this->connection->getUsername()]);
 }
开发者ID:ezsystems,项目名称:ez-support-tools,代码行数:13,代码来源:DoctrineDatabaseSystemInfoCollector.php

示例12: loadGeoData

 /**
  * Fill datatabase with geodata
  *
  * @param Connection $connection
  *
  * @return boolean
  */
 public function loadGeoData($connection)
 {
     $which_output = '';
     $which_ret = '';
     @exec('which mysql', $which_output, $which_ret);
     if (is_array($which_output) && isset($which_output[0])) {
         $mysql_client_command = $which_output[0];
         if (!$this->withMysqlAllIsOk($mysql_client_command)) {
             return false;
         }
         $last_dir = getcwd();
         $work_dir = __DIR__ . '/../../../../install/Resources/sql';
         chdir($work_dir);
         $db_host = $connection->getHost();
         $db_port = $connection->getPort();
         $db_user = $connection->getUsername();
         $db_pass = $connection->getPassword();
         $db_name = $connection->getDatabase();
         $access_params = '';
         $access_params .= ' -h ' . escapeshellarg($db_host);
         if (!empty($db_port)) {
             $access_params .= ' -P ' . escapeshellarg('' . $db_port);
         }
         $access_params .= ' -u ' . escapeshellarg($db_user);
         if (!empty($db_pass)) {
             $access_params .= ' -p' . escapeshellarg($db_pass);
         }
         $access_params .= ' -D ' . escapeshellarg($db_name);
         $cmd_string = escapeshellcmd($mysql_client_command) . $access_params . ' --local-infile=1 < ' . 'geonames.sql';
         $cmd_output = array();
         $cmd_retval = 0;
         exec($cmd_string, $cmd_output, $cmd_retval);
         chdir($last_dir);
         if (!empty($cmd_retval)) {
             return false;
         }
         return true;
     }
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:46,代码来源:DatabaseService.php

示例13: getDBConn

 private function getDBConn(InputInterface $input, OutputInterface $output, Connection $abConn, DialogHelper $dialog)
 {
     $dbConn = $template = null;
     if (!$input->getOption('databox')) {
         do {
             $retry = false;
             $dbName = $dialog->ask($output, 'DataBox name, will not be created if empty : ', null);
             if ($dbName) {
                 try {
                     $dbConn = $this->container['dbal.provider']->get(['host' => $abConn->getHost(), 'port' => $abConn->getPort(), 'user' => $abConn->getUsername(), 'password' => $abConn->getPassword(), 'dbname' => $dbName]);
                     $dbConn->connect();
                     $output->writeln("\n\t<info>Data-Box : Connection successful !</info>\n");
                     do {
                         $template = $dialog->ask($output, 'Choose a language template for metadata structure, available are fr (french) and en (english) (en) : ', 'en');
                     } while (!in_array($template, ['en', 'fr']));
                     $output->writeln("\n\tLanguage selected is <info>'{$template}'</info>\n");
                 } catch (\Exception $e) {
                     $retry = true;
                 }
             } else {
                 $output->writeln("\n\tNo databox will be created\n");
             }
         } while ($retry);
     } else {
         $dbConn = $this->container['dbal.provider']->get(['host' => $input->getOption('db-host'), 'port' => $input->getOption('db-port'), 'user' => $input->getOption('db-user'), 'password' => $input->getOption('db-password'), 'dbname' => $input->getOption('databox')]);
         $dbConn->connect();
         $output->writeln("\n\t<info>Data-Box : Connection successful !</info>\n");
         $template = $input->getOption('db-template') ?: 'en';
     }
     return [$dbConn, $template];
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:31,代码来源:Install.php

示例14: process


//.........这里部分代码省略.........
             FROM `source` t
             LEFT JOIN `source` parent ON t.`parent` = parent.`id`
             WHERE t.`__depth` = @depth
             ORDER BY t.`sort` ASC;');
         $this->db->query('UPDATE `source` t
             JOIN `tmp.Fill` f USING(`id`)
             SET t.`__position` = f.`__position`,
                 t.`__position_depth` = f.`__position_depth`
             ;');
     }
     $this->db->query('SELECT @increment := 0;');
     $this->db->query('TRUNCATE `tmp.Fill`;');
     // Flatten the position numbers
     $this->db->query('INSERT INTO `tmp.Fill`
         SELECT
             t.`id`,
             @increment := @increment+1 AS `__position`,
             0 AS `__position_depth`
         FROM `source` t
         ORDER BY t.`__position` ASC;');
     // And then back to source table
     $this->db->executeUpdate('UPDATE `source` t
         JOIN `tmp.Fill` f USING(`id`)
         SET t.`__position` = f.`__position`
         ;');
     // Relative position
     $this->db->query('SELECT @increment := 0;');
     $this->db->query('TRUNCATE `tmp.Fill`;');
     $this->db->query('INSERT INTO `tmp.Fill`
         SELECT s.`id`, CAST(s.__position - r.__position AS SIGNED) AS `__position`, 0 AS `__position_depth`
         FROM `source` s
         LEFT JOIN `source` r ON s.`__root` = r.`id`;');
     $this->db->query('UPDATE `source` t
         JOIN `tmp.Fill` f USING(`id`)
         SET t.`__position_relative` = f.`__position`;');
     if ($calculateDeltas) {
         $this->db->query('ALTER TABLE source
                 ADD INDEX `root_depth` (`__root`, `__depth`),
                 ADD INDEX `root_relpos` (`__root`, `__position_relative`),
                 ADD INDEX `root_depth_pos` (`__root`, `__depth`, `__position_depth`)
                 ;');
         $this->db->query('CREATE VIEW `out.source` AS
             SELECT
                 source.`id` AS `' . $idColumn . '`,
                 source.`__root` AS `root`,
                 source.`__position` AS `position`,
                 source.`__position_relative` AS `position_relative`,
                 source.`__depth` AS `depth`,
                 IF(source.`__timestamp` - root.`__timestamp` < 0, 0, source.`__timestamp` - root.`__timestamp`)
                     AS `time_delta_runsum`,
                 COALESCE(
                     (source.`__timestamp` - previous.`__timestamp`),
                     (source.`__timestamp` - previous_2.`__timestamp`),
                     (source.`__timestamp` - previous_3.`__timestamp`),
                     0
                 ) AS `time_delta`
             FROM
                 `source` source
                 LEFT JOIN `source` root USE INDEX(`root_depth`)
                     ON source.`__root` = root.`__root` AND root.`__depth` = 0
                 # Same level, direct previous
                 LEFT JOIN `source` previous USE INDEX(`root_relpos`)
                     ON source.`__root`= previous.`__root` AND
                         previous.`__depth` = source.`__depth` AND
                         previous.`__position_relative` = source.`__position_relative` - 1
                 # One level up, direct previous
                 LEFT JOIN `source` previous_2 USE INDEX(`root_relpos`)
                     ON source.`__root`= previous_2.`__root` AND
                         previous_2.`__depth` = source.`__depth` - 1 AND
                         previous_2.`__position_relative` = source.`__position_relative` - 1
                 # No direct previous, finding closest previous on the same level
                 LEFT JOIN `source` previous_3 USE INDEX(`root_depth_pos`)
                     ON source.`__root`= previous_3.`__root` AND
                         previous_3.`__depth` = source.`__depth` AND
                         previous_3.`__position_depth` = source.`__position_depth` - 1
             ;');
     } else {
         $this->db->query('CREATE VIEW `out.source` AS
             SELECT
                 `id` AS `' . $idColumn . '`,
                 `__root` AS `root`,
                 `__position` AS `position`,
                 `__position_relative` AS `position_relative`,
                 `__depth` AS `depth`
             FROM
                 `source`;');
     }
     // Export Data
     $outFile = $outDirectory . DIRECTORY_SEPARATOR . 'destination.csv';
     $command = 'mysql -u ' . $this->db->getUsername() . ' -p' . $this->db->getPassword() . ' -h ' . $this->db->getHost() . ' ' . $this->db->getDatabase() . ' --default-character-set=UTF8 --batch --execute ' . escapeshellarg('SELECT * FROM `out.source`;') . ' --quick | sed \'s/\\t/,/g\' > ' . $outFile;
     $process = new Process($command);
     $process->run();
     if ($process->getExitCode() != 0) {
         $error = $process->getErrorOutput();
         if (!$error) {
             $error = $process->getOutput();
         }
         throw new DBALException('MySQL export error: ' . $error);
     }
 }
开发者ID:keboola,项目名称:php-custom-application-hierarchy,代码行数:101,代码来源:Hierarchy.php

示例15: testGetHost

 public function testGetHost()
 {
     $this->assertEquals('localhost', $this->_conn->getHost());
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:4,代码来源:ConnectionTest.php


注:本文中的Doctrine\DBAL\Connection::getHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。