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


PHP ManagerRegistry::getConnection方法代码示例

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


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

示例1: truncateTable

 protected function truncateTable($class, $connection = null)
 {
     //@TODO Comprendre comment marche exactement getManager et récupérer le manager avec la class
     $tableName = $this->getTableName($class, $connection);
     $connection = $this->managerRegistry->getConnection($connection);
     $connection->exec('DELETE FROM ' . $tableName);
 }
开发者ID:nuxia,项目名称:nuxia-plugin,代码行数:7,代码来源:AbstractDoctrineCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dbname = $input->getArgument('dbname');
     $designdoc = $input->getArgument('designdoc');
     $view = $input->getArgument('view');
     /** @var \Doctrine\CouchDB\CouchDBClient $client */
     $client = $this->registry->getConnection($dbname);
     $query = $client->createViewQuery($designdoc, $view);
     $ret = $query->execute();
     $output->writeln('Updated');
 }
开发者ID:bangpound,项目名称:castle-bundle,代码行数:11,代码来源:UpdateViewCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Bangpound\Bundle\TwitterStreamingBundle\CouchDocument\AtomEntry
     $em = $this->registry->getManager();
     /** @var \Doctrine\CouchDB\CouchDBClient $default_client */
     $default_client = $this->registry->getConnection();
     $tag = $input->getArgument('tag');
     $outputFile = $input->getOption('output');
     $start = \DateTime::createFromFormat('Y-m-d', $input->getOption('start'));
     $end = \DateTime::createFromFormat('Y-m-d', $input->getOption('end'));
     $limit = 1000;
     // Executing the query without grouping allows the view to be refreshed.
     /** @var  $query */
     $query = $default_client->createViewQuery('maint', 'tag');
     if ($input->getOption('stale') !== 'ok') {
         $output->writeln('Updating view.');
         $query->execute();
     }
     // All other executions will allow stale results.
     $query->setGroup(false);
     $query->setIncludeDocs(true);
     $query->setStale('ok');
     $query->setReduce(false);
     $query->setStartKey([$tag, (int) $start->format('Y'), (int) $start->format('m'), (int) $start->format('d')]);
     $query->setEndKey([$tag, (int) $end->format('Y'), (int) $end->format('m'), (int) $end->format('d')]);
     $query->setLimit($limit + 1);
     file_put_contents($outputFile, '[');
     do {
         $result = $query->execute();
         $next_start_key = null;
         if (count($result) > 0) {
             if (count($result) == $limit + 1) {
                 $next_start_key = $result[$limit]['key'];
                 $query->setStartKey($result[$limit]['key']);
                 $query->setStartKeyDocId($result[$limit]['id']);
                 $output->writeln('resume with ' . implode('-', $result[$limit]['key']) . ' ' . $result[$limit]['id']);
             }
             $rows = array();
             foreach ($result as $i => $row) {
                 if ($i < $limit) {
                     $rows[] = json_encode($row['doc']);
                 }
             }
             $data = implode(',', $rows);
             if ($next_start_key) {
                 $data .= ',';
             }
             file_put_contents($outputFile, $data, FILE_APPEND | LOCK_EX);
         }
     } while ($next_start_key);
     file_put_contents($outputFile, ']', FILE_APPEND | LOCK_EX);
 }
开发者ID:bangpound,项目名称:castle-bundle,代码行数:52,代码来源:ExportCommand.php

示例4: putDocumentAction

 /**
  * Handle article PUT
  */
 public function putDocumentAction(Request $request, $id)
 {
     $path = '/' . $id;
     $data = $request->request->all();
     $session = $this->registry->getConnection($this->name);
     $node = $session->getNode($path);
     if (empty($node)) {
         throw new ResourceNotFoundException($path . ' not found');
     }
     $this->fromJsonLD($node, $data);
     $session->save();
     // return the updated version
     $view = View::create($this->toJsonLd($node))->setFormat('json');
     return $this->viewHandler->handle($view, $request);
 }
开发者ID:richardmiller,项目名称:LiipVieBundle,代码行数:18,代码来源:PhpcrController.php

示例5: getPlatform

 /**
  * @return AbstractPlatform
  */
 protected function getPlatform()
 {
     if (!$this->platform) {
         $this->platform = $this->managerRegistry->getConnection()->getDatabasePlatform();
     }
     return $this->platform;
 }
开发者ID:ramunasd,项目名称:platform,代码行数:10,代码来源:SchemaDumperExtension.php

示例6: __construct

 /**
  * Construct AclFilter
  *
  * @DI\InjectParams({
  *     "doctrine" = @DI\Inject("doctrine"),
  *     "securityContext" = @DI\Inject("security.context"),
  *     "aclWalker" = @DI\Inject("%vib.security.acl_walker%"),
  *     "roleHierarchy" = @DI\Inject("%security.role_hierarchy.roles%")
  * })
  * 
  * @param Doctrine\Common\Persistence\ManagerRegistry              $doctrine
  * @param Symfony\Component\Security\Core\SecurityContextInterface $securityContext
  * @param string                                                   $aclWalker
  * @param array                                                    $roleHierarchy
  */
 public function __construct(ManagerRegistry $doctrine, SecurityContextInterface $securityContext, $aclWalker, $roleHierarchy)
 {
     $this->em = $doctrine->getManager();
     $this->securityContext = $securityContext;
     $this->aclConnection = $doctrine->getConnection('default');
     $this->aclWalker = $aclWalker;
     $this->roleHierarchy = $roleHierarchy;
 }
开发者ID:tchern0,项目名称:LabDB,代码行数:23,代码来源:AclFilter.php

示例7: setUp

 protected function setUp()
 {
     $this->registry = new SimpleManagerRegistry(function ($id) {
         switch ($id) {
             case 'default_connection':
                 return $this->createConnection();
             case 'default_manager':
                 return $this->createEntityManager($this->registry->getConnection());
             default:
                 throw new \RuntimeException(sprintf('Unknown service id "%s".', $id));
         }
     });
     $this->serializer = SerializerBuilder::create()->setMetadataDriverFactory(new CallbackDriverFactory(function (array $metadataDirs, Reader $annotationReader) {
         $defaultFactory = new DefaultDriverFactory();
         return new DoctrineTypeDriver($defaultFactory->createDriver($metadataDirs, $annotationReader), $this->registry);
     }))->build();
     $this->prepareDatabase();
 }
开发者ID:dbhattacharjee,项目名称:serializer,代码行数:18,代码来源:IntegrationTest.php

示例8: truncateTable

 /**
  * {@inheritdoc}
  */
 public function truncateTable($className)
 {
     $metadata = $this->getClassMetadata($className);
     if ($metadata instanceof ClassMetadata) {
         $connection = $this->registry->getConnection();
         $connection->beginTransaction();
         try {
             $sql = 'DELETE FROM :table';
             $stmt = $connection->prepare($sql);
             $stmt->bindValue('table', $metadata->getTableName());
             $stmt->execute();
             $connection->commit();
             return true;
         } catch (\Exception $e) {
             $connection->rollback();
         }
     }
     return false;
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:22,代码来源:DoctrineHelper.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Bangpound\Bundle\TwitterStreamingBundle\CouchDocument\AtomEntry
     $em = $this->registry->getManager();
     /** @var \Doctrine\CouchDB\CouchDBClient $default_client */
     $default_client = $this->registry->getConnection();
     $date = \DateTime::createFromFormat('Y-m-d', $input->getArgument('date'));
     $limit = 1000;
     // Executing the query without grouping allows the view to be refreshed.
     /** @var  $query */
     $query = $default_client->createViewQuery('maint', 'date');
     $output->writeln('Updating view.');
     $query->execute();
     // All other executions will allow stale results.
     $query->setGroup(false);
     $query->setIncludeDocs(false);
     $query->setStale('ok');
     $query->setReduce(false);
     $query->setStartKey(array());
     $query->setEndKey(array((int) $date->format('Y'), (int) $date->format('m'), (int) $date->format('d'), array()));
     $query->setLimit($limit + 1);
     do {
         $result = $query->execute();
         $next_start_key = null;
         if (count($result) > 0) {
             if (count($result) == $limit + 1) {
                 $next_start_key = $result[$limit]['key'];
                 $query->setStartKey($result[$limit]['key']);
                 $query->setStartKeyDocId($result[$limit]['id']);
                 $output->writeln('resume with ' . implode('-', $result[$limit]['key']) . ' ' . $result[$limit]['id']);
             }
             $bulk = $default_client->createBulkUpdater();
             foreach ($result as $i => $row) {
                 if ($i < $limit) {
                     $bulk->deleteDocument($row['id'], $row['value']);
                 }
             }
             $result = $bulk->execute();
         }
     } while ($next_start_key);
 }
开发者ID:bangpound,项目名称:castle-bundle,代码行数:41,代码来源:PruneCommand.php

示例10: __construct

 /**
  * Construct AclFilter
  *
  * @DI\InjectParams({
  *     "doctrine" = @DI\Inject("doctrine"),
  *     "tokenStorage" = @DI\Inject("security.token_storage"),
  *     "aclWalker" = @DI\Inject("%bluemesa_acl.walker%"),
  *     "roleHierarchy" = @DI\Inject("%security.role_hierarchy.roles%")
  * })
  * 
  * @param  ManagerRegistry        $doctrine
  * @param  TokenStorageInterface  $tokenStorage
  * @param  string                 $aclWalker
  * @param  array                  $roleHierarchy
  * @throws Exception
  */
 public function __construct(ManagerRegistry $doctrine, TokenStorageInterface $tokenStorage, $aclWalker, $roleHierarchy)
 {
     $em = $doctrine->getManager();
     if (!$em instanceof EntityManager) {
         throw new Exception();
     }
     $this->em = $em;
     $this->tokenStorage = $tokenStorage;
     $this->aclConnection = $doctrine->getConnection('default');
     $this->aclWalker = $aclWalker;
     $this->roleHierarchy = $roleHierarchy;
 }
开发者ID:BlueMesa,项目名称:AclBundle,代码行数:28,代码来源:AclFilter.php

示例11: getConnection

 /**
  * @param $name
  * @return object
  */
 public function getConnection($name)
 {
     return $this->managerRegistry->getConnection($name);
 }
开发者ID:saxulum,项目名称:saxulum-doctrine-mongodb-odm-commands,代码行数:8,代码来源:ManagerRegistryHelper.php

示例12: isReservedWord

 /**
  * Determines whether the given value is reserved SQL word or not
  *
  * @param string $value
  * @return bool
  */
 protected function isReservedWord($value)
 {
     return $this->doctrine->getConnection()->getDatabasePlatform()->getReservedKeywordsList()->isKeyword($value);
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:NotSqlKeywordValidator.php

示例13: getForConnection

 /**
  * @param string|null $name
  *
  * @return Configuration
  */
 public function getForConnection($name = null)
 {
     $connection = $this->registry->getConnection($name);
     return $this->factory->make($connection);
 }
开发者ID:nikolajlovenhardt,项目名称:migrations,代码行数:10,代码来源:ConfigurationProvider.php


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