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


PHP EntityManager::getConnection方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param Repository $repository
  */
 public function __construct(Repository $repository)
 {
     $this->repository = $repository;
     $this->manager = $repository->getManager();
     $this->metadata = $repository->getMetadata();
     $this->query = $this->manager->getConnection()->createQueryBuilder()->from($this->metadata->getTable());
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:12,代码来源:QueryBuilder.php

示例2: _generateDiscriminatorColumnConditionSQL

 /**
  * Generates a discriminator column SQL condition for the class with the given DQL alias.
  *
  * @param array $dqlAliases List of root DQL aliases to inspect for discriminator restrictions.
  * @return string
  */
 private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases)
 {
     $encapsulate = false;
     $sql = '';
     foreach ($dqlAliases as $dqlAlias) {
         $class = $this->_queryComponents[$dqlAlias]['metadata'];
         if ($class->isInheritanceTypeSingleTable()) {
             $conn = $this->_em->getConnection();
             $values = array();
             if ($class->discriminatorValue !== null) {
                 // discrimnators can be 0
                 $values[] = $conn->quote($class->discriminatorValue);
             }
             foreach ($class->subClasses as $subclassName) {
                 $values[] = $conn->quote($this->_em->getClassMetadata($subclassName)->discriminatorValue);
             }
             if ($sql != '') {
                 $sql .= ' AND ';
                 $encapsulate = true;
             }
             $sql .= ($sql != '' ? ' AND ' : '') . ($this->_useSqlTableAliases ? $this->getSqlTableAlias($class->table['name'], $dqlAlias) . '.' : '') . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')';
         }
     }
     return $encapsulate ? '(' . $sql . ')' : $sql;
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:31,代码来源:SqlWalker.php

示例3: getConnection

 public function getConnection()
 {
     $classMetadata = array();
     $this->em = $this->createEntityManager();
     $conn = $this->em->getConnection();
     $pdo = $conn->getWrappedConnection();
     $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
     if (count($this->classes) > 0) {
         foreach ($this->classes as $class) {
             $classMetadata[] = $this->em->getClassMetadata($class);
         }
     } else {
         throw new \Doctrine\ORM\ORMException("No associated classes not yet implemented.");
     }
     $schemaTool->createSchema($classMetadata);
     return $this->createDefaultDBConnection($pdo, $conn->getDatabase());
 }
开发者ID:Edadeal,项目名称:YamlExportBundle,代码行数:17,代码来源:FunctionalTestCase.php

示例4: testAuditable

 public function testAuditable()
 {
     $user = new UserAudit("beberlei");
     $article = new ArticleAudit("test", "yadda!", $user, 'text');
     $this->em->persist($user);
     $this->em->persist($article);
     $this->em->flush();
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT * FROM UserAudit_audit')));
     $this->assertEquals(1, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
     $article->setText("oeruoa");
     $this->em->flush();
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
     $this->em->remove($user);
     $this->em->remove($article);
     $this->em->flush();
     $this->assertEquals(3, count($this->em->getConnection()->fetchAll('SELECT id FROM revisions')));
     $this->assertEquals(2, count($this->em->getConnection()->fetchAll('SELECT * FROM UserAudit_audit')));
     $this->assertEquals(3, count($this->em->getConnection()->fetchAll('SELECT * FROM ArticleAudit_audit')));
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:21,代码来源:FunctionalTest.php

示例5: _generateDiscriminatorColumnConditionSql

 /**
  * Generates a discriminator column SQL condition for the class with the given DQL alias.
  *
  * @param string $dqlAlias
  * @return string
  */
 private function _generateDiscriminatorColumnConditionSql($dqlAlias)
 {
     $sql = '';
     if ($dqlAlias) {
         $class = $this->_queryComponents[$dqlAlias]['metadata'];
         if ($class->isInheritanceTypeSingleTable()) {
             $conn = $this->_em->getConnection();
             $values = array($conn->quote($class->discriminatorValue));
             foreach ($class->subClasses as $subclassName) {
                 $values[] = $conn->quote($this->_em->getClassMetadata($subclassName)->discriminatorValue);
             }
             $sql .= ($this->_useSqlTableAliases ? $this->getSqlTableAlias($class->primaryTable['name'], $dqlAlias) . '.' : '') . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')';
         }
     }
     return $sql;
 }
开发者ID:andreia,项目名称:doctrine,代码行数:22,代码来源:SqlWalker.php

示例6: _generateDiscriminatorColumnConditionSQL

 /**
  * Generates a discriminator column SQL condition for the class with the given DQL alias.
  *
  * @param array $dqlAliases List of root DQL aliases to inspect for discriminator restrictions.
  * @return string
  */
 private function _generateDiscriminatorColumnConditionSQL(array $dqlAliases)
 {
     $sqlParts = array();
     foreach ($dqlAliases as $dqlAlias) {
         $class = $this->queryComponents[$dqlAlias]['metadata'];
         if (!$class->isInheritanceTypeSingleTable()) {
             continue;
         }
         $conn = $this->em->getConnection();
         $values = array();
         if ($class->discriminatorValue !== null) {
             // discrimnators can be 0
             $values[] = $conn->quote($class->discriminatorValue);
         }
         foreach ($class->subClasses as $subclassName) {
             $values[] = $conn->quote($this->em->getClassMetadata($subclassName)->discriminatorValue);
         }
         $sqlParts[] = ($this->useSqlTableAliases ? $this->getSQLTableAlias($class->getTableName(), $dqlAlias) . '.' : '') . $class->discriminatorColumn['name'] . ' IN (' . implode(', ', $values) . ')';
     }
     $sql = implode(' AND ', $sqlParts);
     return count($sqlParts) > 1 ? '(' . $sql . ')' : $sql;
 }
开发者ID:bardascat,项目名称:blogify,代码行数:28,代码来源:SqlWalker.php

示例7: truncate

 /**
  * Truncate the table for the current entity.
  *
  * @throws \Doctrine\DBAL\DBALException
  */
 public static function truncate()
 {
     $connection = \EntityManager::getConnection();
     $platform = $connection->getDatabasePlatform();
     $connection->executeUpdate($platform->getTruncateTableSQL(self::getTable(), false));
 }
开发者ID:LeeKevin,项目名称:laravel-api,代码行数:11,代码来源:DoctrineEntity.php

示例8: __construct

 /**
  * Constructor.
  *
  * @param EntityManager $manager
  * @param Metadata      $metadata
  */
 public function __construct(EntityManager $manager, Metadata $metadata)
 {
     $this->manager = $manager;
     $this->metadata = $metadata;
     $this->query = $manager->getConnection()->createQueryBuilder()->from($metadata->getTable());
 }
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:12,代码来源:QueryBuilder.php

示例9: getConnection

 /**
  * 
  * @return \dbrecord\Connection
  */
 public function getConnection()
 {
     return $this->em->getConnection();
 }
开发者ID:matak,项目名称:dbrecord,代码行数:8,代码来源:EntityRepository.php


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