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


PHP Connection::getParams方法代码示例

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


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

示例1: getQuery

 /**
  * @throws \RuntimeException
  * @return string
  */
 public function getQuery()
 {
     $config = $this->connection->getParams();
     $driver = $config['driver'];
     if (!isset($this->configClasses[$driver])) {
         throw new \RuntimeException('Driver "%s" not found');
     }
     /** @var PdoMysql $className */
     $className = $this->configClasses[$driver];
     return $className::getPlainSql();
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:FulltextIndexManager.php

示例2: getDatabase

 /**
  * {@inheritdoc}
  */
 public function getDatabase(\Doctrine\DBAL\Connection $conn)
 {
     $params = $conn->getParams();
     if (isset($params['dbname'])) {
         return $params['dbname'];
     }
     return null;
 }
开发者ID:balalaikaboy,项目名称:CassandraPDO4Doctrine,代码行数:11,代码来源:Driver.php

示例3: add

 /**
  * Add a connection to the pool
  *
  * @param Connection $connection
  */
 public function add(Connection $connection)
 {
     $key = md5(serialize($connection->getParams()));
     if (isset($this->connections[$key]) && $connection !== $this->connections[$key]) {
         throw new \InvalidArgumentException('Expects a non registered connection.');
     }
     $this->connections[$key] = $connection;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:13,代码来源:ConnectionPoolManager.php

示例4: getDatabase

 public function getDatabase(\Doctrine\DBAL\Connection $conn)
 {
     $params = $conn->getParams();
     if (isset($params['dbname'])) {
         return $params['dbname'];
     }
     return $conn->query('SELECT DATABASE()')->fetchColumn();
 }
开发者ID:laiello,项目名称:masfletes,代码行数:8,代码来源:Driver.php

示例5: __construct

 /**
  * @param Connection $conn
  * @param string $generatorTableName
  */
 public function __construct(Connection $conn, $generatorTableName = 'sequences')
 {
     $params = $conn->getParams();
     if ($params['driver'] == 'pdo_sqlite') {
         throw new \Doctrine\DBAL\DBALException("Cannot use TableGenerator with SQLite.");
     }
     $this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager());
     $this->generatorTableName = $generatorTableName;
 }
开发者ID:rdohms,项目名称:dbal,代码行数:13,代码来源:TableGenerator.php

示例6: dropDatabaseForConnection

 protected function dropDatabaseForConnection(Connection $connection, OutputInterface $output)
 {
     $params = $connection->getParams();
     $name = isset($params['path']) ? $params['path'] : $params['dbname'];
     try {
         $connection->getSchemaManager()->dropDatabase($name);
         $output->writeln(sprintf('<info>Dropped database for connection named <comment>%s</comment></info>', $name));
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Could not drop database for connection named <comment>%s</comment></error>', $name));
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
 }
开发者ID:pgodel,项目名称:PageRoller,代码行数:12,代码来源:DropDatabaseDoctrineCommand.php

示例7: createNewscoopDatabase

 /**
  * Create Newscoop Database
  *
  * @param Connection $connection
  */
 public function createNewscoopDatabase($connection)
 {
     $params = $connection->getParams();
     if (isset($params['master'])) {
         $params = $params['master'];
     }
     unset($params['dbname']);
     $tmpConnection = DriverManager::getConnection($params);
     $name = $tmpConnection->getDatabasePlatform()->quoteSingleIdentifier($connection->getDatabase());
     $tmpConnection->getSchemaManager()->createDatabase($name);
     unset($tmpConnection);
     $this->logger->addInfo('Database ' . $name . ' created');
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:18,代码来源:DatabaseService.php

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

示例9: __construct

 public function __construct(Connection $db = null, $tableName, $tableAlias = null, $tablesAliases = null)
 {
     $this->db = $db;
     $this->tableName = $tableName;
     $this->tableAlias = $tableAlias;
     $this->tablesAliases = $tablesAliases;
     $this->table = $this->tableAlias !== null ? $this->tableAlias : "`{$this->tableName}`";
     if ($db !== null && $db->getParams()['driver'] !== 'pdo_sqlite') {
         $tableColumns = $db->executeQuery("DESCRIBE {$tableName}")->fetchAll(\PDO::FETCH_COLUMN);
         $this->isTimestampable = count(array_intersect(['created_at', 'updated_at'], $tableColumns)) == 2;
         $this->isSoftdeletable = in_array('deleted_at', $tableColumns);
     }
 }
开发者ID:pym,项目名称:table,代码行数:13,代码来源:Table.php

示例10: createSchemaConfig

 /**
  * Creates the configuration for this schema.
  *
  * @return \Doctrine\DBAL\Schema\SchemaConfig
  */
 public function createSchemaConfig()
 {
     $schemaConfig = new SchemaConfig();
     $schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength());
     $searchPaths = $this->getSchemaSearchPaths();
     if (isset($searchPaths[0])) {
         $schemaConfig->setName($searchPaths[0]);
     }
     $params = $this->_conn->getParams();
     if (isset($params['defaultTableOptions'])) {
         $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']);
     }
     return $schemaConfig;
 }
开发者ID:tamboer,项目名称:LaravelOctober,代码行数:19,代码来源:AbstractSchemaManager.php

示例11: createDatabaseForConnection

 protected function createDatabaseForConnection(Connection $connection, OutputInterface $output)
 {
     $params = $connection->getParams();
     $name = isset($params['path']) ? $params['path'] : $params['dbname'];
     unset($params['dbname']);
     $tmpConnection = \Doctrine\DBAL\DriverManager::getConnection($params);
     try {
         $tmpConnection->getSchemaManager()->createDatabase($name);
         $output->writeln(sprintf('<info>Created database for connection named <comment>%s</comment></info>', $name));
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>Could not create database for connection named <comment>%s</comment></error>', $name));
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
     $tmpConnection->close();
 }
开发者ID:robo47,项目名称:symfony,代码行数:15,代码来源:CreateDatabaseDoctrineCommand.php

示例12: __construct

 /**
  * @param \Doctrine\DBAL\Connection $conn
  *
  * @throws \Doctrine\DBAL\Sharding\ShardingException
  */
 public function __construct(Connection $conn)
 {
     $this->conn = $conn;
     $params = $conn->getParams();
     if (!isset($params['sharding']['federationName'])) {
         throw ShardingException::missingDefaultFederationName();
     }
     if (!isset($params['sharding']['distributionKey'])) {
         throw ShardingException::missingDefaultDistributionKey();
     }
     if (!isset($params['sharding']['distributionType'])) {
         throw ShardingException::missingDistributionType();
     }
     $this->federationName = $params['sharding']['federationName'];
     $this->distributionKey = $params['sharding']['distributionKey'];
     $this->distributionType = $params['sharding']['distributionType'];
     $this->filteringEnabled = isset($params['sharding']['filteringEnabled']) ? (bool) $params['sharding']['filteringEnabled'] : false;
 }
开发者ID:neteasy-work,项目名称:hkgbf_crm,代码行数:23,代码来源:SQLAzureShardManager.php

示例13: mysql_connect

 /**
  * Connect using the deprecated mysql extension.
  *
  * This method is often required when working with some legacy admin pages.
  *
  * Most people won't need this, but it is here if they do.
  *
  * @param array $params an array of mysql connection optons that match the PDO dsn.
  *                     If you do not specify any parameters. it will use the
  *                     <code>apps.store.database.default</code> settings.
  * @return resource an ext/mysql resource
  */
 public function mysql_connect($params = null)
 {
     if (!extension_loaded('mysql')) {
         throw new \RuntimeException('The mysql extension must be installed to use this method.');
     }
     $defaults = $this->conn->getParams();
     $params = array_merge($defaults, (array) $params);
     $link = mysql_connect($params['host'], $params['user'], $params['password'], true);
     if (is_resource($link) && mysql_select_db($params['dbname'])) {
         if (!isset($params['charset']) && !empty($params['charset'])) {
             mysql_set_charset($params['charset']);
         }
         $this->link = $link;
         return $this->link;
     } else {
         throw new RuntimeException(mysql_error(), mysql_errno());
     }
 }
开发者ID:zenmagick,项目名称:zenmagick,代码行数:30,代码来源:QueryFactory.php

示例14: getServerVersion

 private function getServerVersion()
 {
     $params = $this->con->getParams();
     // Explicit platform version requested (supersedes auto-detection), so we respect it.
     if (isset($params['serverVersion'])) {
         return $params['serverVersion'];
     }
     $wrappedConnection = $this->con->getWrappedConnection();
     if ($wrappedConnection instanceof ServerInfoAwareConnection) {
         return $wrappedConnection->getServerVersion();
     }
     // Support DBAL 2.4 by accessing it directly when using PDO PgSQL
     if ($wrappedConnection instanceof \PDO) {
         return $wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION);
     }
     // If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks.
     return '';
 }
开发者ID:ayoah,项目名称:symfony,代码行数:18,代码来源:DbalSessionHandler.php

示例15: __construct

 public function __construct(Connection $conn)
 {
     $this->pdo = $conn;
     $params = $conn->getParams();
     $driver = $params['driver'];
     $commands = [];
     switch ($driver) {
         case 'pdo_mysql':
             $commands[] = 'SET SQL_MODE=ANSI_QUOTES';
             break;
         case 'pdo_sqlite':
             break;
         case 'pdo_pgsql':
             break;
         case 'pdo_oci':
             break;
         case 'pdo_sqlsrv':
             $commands[] = 'SET QUOTED_IDENTIFIER ON';
             break;
     }
     foreach ($commands as $comm) {
         $this->pdo->exec($comm);
     }
 }
开发者ID:php-go,项目名称:db-doctrine,代码行数:24,代码来源:MedooAdapter.php


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