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


PHP Connection::getConfiguration方法代码示例

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


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

示例1: singleImport

 private function singleImport($config, OutputInterface &$output, $entity_key = null)
 {
     $this->connection = $this->connectionFactory->createConnection($config['database']);
     $this->connection->getConfiguration()->getSQLLogger(null);
     if ($entity_key) {
         if (!isset($config['maps'][$entity_key])) {
             throw new \Exception("Entity alias not found: " . $entity_key);
         }
         $map = $config['maps'][$entity_key];
         if (!$this->container->has($map['old_data']['service_id'])) {
             throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
         }
         $result = $this->importEntity($map);
         $output->writeln("<info>Total " . count($result) . " {$entity_key} imported </info>");
     } else {
         foreach ((array) $config['maps'] as $key => $map) {
             if (!$this->container->has($map['old_data']['service_id'])) {
                 throw new \Exception("Service not exists: " . $map['old_data']['service_id']);
             }
             $offset = 0;
             do {
                 $result = $this->importEntity($map);
                 $output->writeln("<info>Total " . count($result) . " {$key} imported </info>");
                 if (!$result) {
                     break;
                 }
                 $offset++;
                 $this->setOffset($offset);
             } while (true);
         }
     }
     $this->connection->close();
 }
开发者ID:hmert,项目名称:importbundle,代码行数:33,代码来源:ImportManager.php

示例2: setUp

 /**
  * Initializes the database (once).
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\Tools\ToolsException
  */
 protected function setUp()
 {
     if (null === static::$_conn) {
         $dbPath = __DIR__ . '/../../../db.sqlite';
         if (file_exists($dbPath)) {
             unlink($dbPath);
         }
         $params = ['driver' => 'pdo_sqlite', 'path' => $dbPath];
         static::$_conn = DriverManager::getConnection($params);
         static::$_conn->getConfiguration()->setSQLLogger(null);
     }
     if (null === static::$_em) {
         $paths = [__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/ORM/Resources/mapping'];
         $isDevMode = true;
         $config = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
         $em = EntityManager::create(static::$_conn, $config);
         $classes = [];
         foreach (static::$_classes as $class) {
             array_push($classes, $em->getClassMetadata($class));
         }
         $schemaTool = new SchemaTool($em);
         $schemaTool->dropSchema($classes);
         $schemaTool->createSchema($classes);
         // Load fixtures
         $loader = new Loader();
         $loader->loadFromDirectory(__DIR__ . '/../../../../../src/Ekyna/Commerce/Bridge/Doctrine/Fixtures');
         $purger = new ORMPurger();
         $executor = new ORMExecutor($em, $purger);
         $executor->execute($loader->getFixtures());
         static::$_em = $em;
     }
 }
开发者ID:ekyna,项目名称:commerce,代码行数:39,代码来源:DatabaseTestCase.php

示例3: setConnection

 public function setConnection(Connection $conn)
 {
     $this->conn = $conn;
     if ($this->debug) {
         $this->logger = new DebugStack();
         $this->conn->getConfiguration()->setSQLLogger($this->logger);
     }
 }
开发者ID:dongww,项目名称:simple-db,代码行数:8,代码来源:ManagerFactory.php

示例4: runQuery

 /**
  * @param $sql
  * @return \Doctrine\DBAL\Driver\Statement
  * @throws \Doctrine\DBAL\DBALException
  */
 public static function runQuery($sql)
 {
     if (null === static::$dblaConnInstance) {
         static::$dblaConnInstance = DriverManager::getConnection(static::getParamsConnection(), new Configuration());
         static::$dblaConnInstance->getConfiguration()->setSQLLogger(self::logger());
     }
     return static::$dblaConnInstance->query($sql);
 }
开发者ID:lacteosdelcesar,项目名称:s3-untitledApi-K,代码行数:13,代码来源:EntityManager.php

示例5: setResultCache

 /**
  * Set a caching method.
  *
  * It will not override an already set result cache
  *
  * @param Doctrine\Common\Cache\Cache a Cache interface
  */
 public function setResultCache(Cache $cache)
 {
     $config = $this->conn->getConfiguration();
     $this->hasResultCache = null != $config->getResultCacheImpl();
     if (!$this->hasResultCache) {
         $config->setResultCacheImpl($cache);
         $this->hasResultCache = true;
     }
 }
开发者ID:zenmagick,项目名称:zenmagick,代码行数:16,代码来源:QueryFactory.php

示例6: setUp

 protected function setUp()
 {
     if (!isset(self::$_sharedConn)) {
         self::$_sharedConn = TestUtil::getConnection();
     }
     $this->_conn = self::$_sharedConn;
     $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack();
     $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
 }
开发者ID:llinder,项目名称:FrameworkBenchmarks,代码行数:9,代码来源:DbalFunctionalTestCase.php

示例7: setUp

 public function setUp()
 {
     if (!isset(self::$_sharedConn)) {
         $params = array('driverClass' => 'Crate\\DBAL\\Driver\\PDOCrate\\Driver', 'host' => 'localhost', 'port' => 4200);
         self::$_sharedConn = \Doctrine\DBAL\DriverManager::getConnection($params);
     }
     $this->_conn = self::$_sharedConn;
     $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack();
     $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack);
 }
开发者ID:crate,项目名称:crate-dbal,代码行数:10,代码来源:DBALFunctionalTestCase.php

示例8: setConnection

 /**
  * @param \Doctrine\DBAL\Connection $connection
  * @throws \Nette\InvalidStateException
  */
 public function setConnection(Doctrine\DBAL\Connection $connection)
 {
     if ($this->connection !== NULL) {
         throw new Nette\InvalidStateException("Doctrine Panel is already bound to connection.");
     }
     if (($logger = $connection->getConfiguration()->getSQLLogger()) instanceof Doctrine\DBAL\Logging\LoggerChain) {
         $logger->addLogger($this);
     } else {
         $connection->getConfiguration()->setSQLLogger($this);
     }
     $this->connection = $connection;
 }
开发者ID:pt24,项目名称:doctrine,代码行数:16,代码来源:Panel.php

示例9: _getConnection

 protected function _getConnection()
 {
     if (!isset(self::$_conn)) {
         self::$_conn = DriverManager::getConnection($this->_getDbParams(), new Configuration());
         self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
         Configurator::configure(self::$_conn->getConfiguration());
         if (!Type::hasType('tsvector')) {
             Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
         }
         $platform = self::$_conn->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
     }
     return self::$_conn;
 }
开发者ID:jsor,项目名称:doctrine-postgis,代码行数:14,代码来源:AbstractFunctionalTestCase.php

示例10: _getConnection

 protected function _getConnection()
 {
     if (!isset(self::$_conn)) {
         $dbParams = array('driver' => $GLOBALS['db_type'], 'user' => $GLOBALS['db_username'], 'password' => $GLOBALS['db_password'], 'host' => $GLOBALS['db_host'], 'dbname' => $GLOBALS['db_name'], 'port' => $GLOBALS['db_port']);
         self::$_conn = DriverManager::getConnection($dbParams, new Configuration());
         self::$_conn->getEventManager()->addEventSubscriber(new ORMSchemaEventSubscriber());
         Configurator::configure(self::$_conn->getConfiguration());
         if (!Type::hasType('tsvector')) {
             Type::addType('tsvector', 'Doctrine\\DBAL\\Types\\TextType');
         }
         $platform = self::$_conn->getDatabasePlatform();
         $platform->registerDoctrineTypeMapping('tsvector', 'tsvector');
     }
     return self::$_conn;
 }
开发者ID:novikovsergey,项目名称:doctrine-postgis,代码行数:15,代码来源:AbstractFunctionalTestCase.php

示例11: getDiff

 /**
  * @param Schema $targetSchema
  * @param \Doctrine\DBAL\Connection $connection
  * @return \Doctrine\DBAL\Schema\SchemaDiff
  * @throws DBALException
  */
 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     // adjust varchar columns with a length higher then getVarcharMaxLength to clob
     foreach ($targetSchema->getTables() as $table) {
         foreach ($table->getColumns() as $column) {
             if ($column->getType() instanceof StringType) {
                 if ($column->getLength() > $connection->getDatabasePlatform()->getVarcharMaxLength()) {
                     $column->setType(Type::getType('text'));
                     $column->setLength(null);
                 }
             }
         }
     }
     $filterExpression = $this->getFilterExpression();
     $this->connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
     $sourceSchema = $connection->getSchemaManager()->createSchema();
     // remove tables we don't know about
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($sourceSchema->getTables() as $table) {
         if (!$targetSchema->hasTable($table->getName())) {
             $sourceSchema->dropTable($table->getName());
         }
     }
     // remove sequences we don't know about
     foreach ($sourceSchema->getSequences() as $table) {
         if (!$targetSchema->hasSequence($table->getName())) {
             $sourceSchema->dropSequence($table->getName());
         }
     }
     $comparator = new Comparator();
     return $comparator->compare($sourceSchema, $targetSchema);
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:38,代码来源:Migrator.php

示例12: __construct

 /**
  * Initializes a new <tt>StandardEntityPersister</tt> that uses the given EntityManager
  * and persists instances of the class described by the given class metadata descriptor.
  * 
  * @param EntityManager $em
  * @param ClassMetadata $class
  */
 public function __construct(EntityManager $em, ClassMetadata $class)
 {
     $this->_em = $em;
     $this->_class = $class;
     $this->_conn = $em->getConnection();
     $this->_sqlLogger = $this->_conn->getConfiguration()->getSqlLogger();
     $this->_platform = $this->_conn->getDatabasePlatform();
 }
开发者ID:andreia,项目名称:doctrine,代码行数:15,代码来源:StandardEntityPersister.php

示例13: enableLogging

 public function enableLogging()
 {
     if ($this->connection === NULL) {
         throw new Kdyby\Doctrine\InvalidStateException("Doctrine Panel is not bound to connection.");
     }
     $config = $this->connection->getConfiguration();
     $logger = $config->getSQLLogger();
     if ($logger instanceof Doctrine\DBAL\Logging\LoggerChain) {
         $logger->addLogger($this);
     } else {
         $config->setSQLLogger($this);
     }
 }
开发者ID:LidskaSila,项目名称:Doctrine,代码行数:13,代码来源:Panel.php

示例14: execute

 /**
  * Executes the statement with the currently bound parameters.
  *
  * @param array|null $params
  *
  * @return boolean TRUE on success, FALSE on failure.
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public function execute($params = null)
 {
     if (is_array($params)) {
         $this->params = $params;
     }
     $logger = $this->conn->getConfiguration()->getSQLLogger();
     if ($logger) {
         $logger->startQuery($this->sql, $this->params, $this->types);
     }
     try {
         $stmt = $this->stmt->execute($params);
     } catch (\Exception $ex) {
         throw DBALException::driverExceptionDuringQuery($ex, $this->sql, $this->conn->resolveParams($this->params, $this->types));
     }
     if ($logger) {
         $logger->stopQuery();
     }
     $this->params = array();
     $this->types = array();
     return $stmt;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:30,代码来源:Statement.php

示例15: getDiff

 protected function getDiff(Schema $targetSchema, \Doctrine\DBAL\Connection $connection)
 {
     $filterExpression = $this->getFilterExpression();
     $this->connection->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
     $sourceSchema = $connection->getSchemaManager()->createSchema();
     // remove tables we don't know about
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($sourceSchema->getTables() as $table) {
         if (!$targetSchema->hasTable($table->getName())) {
             $sourceSchema->dropTable($table->getName());
         }
     }
     // remove sequences we don't know about
     foreach ($sourceSchema->getSequences() as $table) {
         if (!$targetSchema->hasSequence($table->getName())) {
             $sourceSchema->dropSequence($table->getName());
         }
     }
     $comparator = new Comparator();
     return $comparator->compare($sourceSchema, $targetSchema);
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:21,代码来源:migrator.php


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