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


PHP Connection::getPort方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: testGetPort

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

示例5: getPort

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

示例6: 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

示例7: 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

示例8: createConnectionErrorMessage

 /**
  * Create the message we want to throw, if there was a connection error.
  *
  * @param Connection $connection The connection.
  *
  * @return string The message we want throw if there was a connection error.
  */
 protected function createConnectionErrorMessage($connection)
 {
     $message = 'Not connected to database. dsn: ' . $connection->getDriver()->getName() . '://' . '****:****@' . $connection->getHost() . ':' . $connection->getPort() . '/' . $connection->getDatabase();
     return $message;
 }
开发者ID:Alpha-Sys,项目名称:oxideshop_ce,代码行数:12,代码来源:Database.php

示例9: getPort

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

示例10: 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

示例11: 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

示例12: createConfigFile

 private function createConfigFile(Connection $abConn, $serverName, $binaryData)
 {
     $config = $this->app['configuration.store']->initialize()->getConfig();
     $config['main']['database']['host'] = $abConn->getHost();
     $config['main']['database']['port'] = $abConn->getPort();
     $config['main']['database']['user'] = $abConn->getUsername();
     $config['main']['database']['password'] = $abConn->getPassword();
     $config['main']['database']['dbname'] = $abConn->getDatabase();
     $config['main']['database']['driver'] = 'pdo_mysql';
     $config['main']['database']['charset'] = 'UTF8';
     $config['main']['binaries'] = $binaryData;
     $config['servername'] = $serverName;
     $config['main']['key'] = md5(mt_rand(100000000, 999999999));
     $this->app['configuration.store']->setConfig($config);
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:15,代码来源:Installer.php


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