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


PHP EntityManager::create方法代码示例

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


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

示例1: createMemoryManager

 /**
  * @return Kdyby\Doctrine\EntityManager
  */
 protected function createMemoryManager($classNames = NULL, $createSchema = TRUE)
 {
     $conf = ['driver' => 'pdo_sqlite', 'memory' => TRUE];
     $connection = new Kdyby\Doctrine\Connection($conf, new Driver());
     $config = new Kdyby\Doctrine\Configuration();
     $cache = new ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(TEMP_DIR);
     $config->setProxyNamespace('TestProxy');
     $config->setDefaultRepositoryClassName('Kdyby\\Doctrine\\EntityRepository');
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([__DIR__ . '/Model/', VENDOR_DIR], FALSE));
     $em = Kdyby\Doctrine\EntityManager::create($connection, $config);
     $em->getEventManager()->addEventSubscriber(new SortableListener());
     if ($createSchema === FALSE) {
         return $em;
     }
     $schemaTool = new SchemaTool($em);
     if ($classNames !== NULL) {
         $meta = [];
         foreach ((array) $classNames as $className) {
             $meta[] = $em->getClassMetadata($className);
         }
     } else {
         $meta = $em->getMetadataFactory()->getAllMetadata();
     }
     $schemaTool->createSchema($meta);
     return $em;
 }
开发者ID:librette,项目名称:doctrine-sortable,代码行数:32,代码来源:EMTest.php

示例2: setUp

 protected function setUp()
 {
     $config = new \Kdyby\Doctrine\Configuration();
     $mapping = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(new \Doctrine\Common\Annotations\AnnotationReader(), [__DIR__ . '/entitites']);
     $config->setMetadataDriverImpl($mapping);
     $config->setProxyDir(__DIR__ . '/proxy');
     $config->setProxyNamespace('Tests\\_ProxyTests');
     \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../../vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $event = new \Doctrine\Common\EventManager();
     $conn = new \Kdyby\Doctrine\Connection(array('dbname' => 'test', 'user' => 'travis', 'password' => '', 'host' => 'localhost', 'driver' => 'pdo_mysql'), new \Doctrine\DBAL\Driver\PDOMySql\Driver(), $config, $event);
     $em = \Kdyby\Doctrine\EntityManager::create($conn, $config, $event);
     $this->helper = new \WebChemistry\Forms\Doctrine($em);
 }
开发者ID:webchemistry,项目名称:forms-doctrine,代码行数:13,代码来源:ToArrayTest.php

示例3: createMemoryManager

 /**
  * @return Kdyby\Doctrine\EntityManager
  */
 protected function createMemoryManager($createSchema = TRUE)
 {
     $conf = ['driver' => 'pdo_sqlite', 'memory' => TRUE];
     $connection = new Kdyby\Doctrine\Connection($conf, new Driver());
     $config = new Kdyby\Doctrine\Configuration();
     $cache = new ArrayCache();
     $config->setMetadataCacheImpl($cache);
     $config->setQueryCacheImpl($cache);
     $config->setProxyDir(TEMP_DIR);
     $config->setProxyNamespace('TestProxy');
     $config->setDefaultRepositoryClassName(Kdyby\Doctrine\EntityDao::class);
     $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver([__DIR__], FALSE));
     $em = Kdyby\Doctrine\EntityManager::create($connection, $config);
     if ($createSchema === FALSE) {
         return $em;
     }
     $schemaTool = new SchemaTool($em);
     $meta = $em->getMetadataFactory()->getAllMetadata();
     $schemaTool->createSchema($meta);
     return $em;
 }
开发者ID:librette,项目名称:doctrine-queries,代码行数:24,代码来源:EntityManagerTest.php


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