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


PHP ResultSetMappingBuilder::addJoinedEntityFromClassMetadata方法代码示例

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


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

示例1: testUnknownParentAliasThrowsException

 /**
  * @group PR-39
  */
 public function testUnknownParentAliasThrowsException()
 {
     $rsm = new ResultSetMappingBuilder($this->_em);
     $rsm->addRootEntityFromClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'u');
     $rsm->addJoinedEntityFromClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsAddress', 'a', 'un', 'address', array('id' => 'a_id'));
     $query = $this->_em->createNativeQuery('SELECT u.*, a.*, a.id AS a_id FROM cms_users u INNER JOIN cms_addresses a ON u.id = a.user_id WHERE u.username = ?', $rsm);
     $query->setParameter(1, 'romanb');
     $this->setExpectedException("Doctrine\\ORM\\Internal\\Hydration\\HydrationException", "The parent object of entity result with alias 'a' was not found. The parent alias is 'un'.");
     $users = $query->getResult();
 }
开发者ID:relo-san,项目名称:doctrine2,代码行数:13,代码来源:NativeQueryTest.php

示例2: testIssue

 public function testIssue()
 {
     $config = $this->_em->getConfiguration();
     $config->addEntityNamespace('MyNamespace', 'Doctrine\\Tests\\ORM\\Functional\\Ticket');
     $user = new DDC2256User();
     $user->name = 'user';
     $group = new DDC2256Group();
     $group->name = 'group';
     $user->group = $group;
     $this->_em->persist($user);
     $this->_em->persist($group);
     $this->_em->flush();
     $this->_em->clear();
     $sql = 'SELECT u.id, u.name, g.id as group_id, g.name as group_name FROM ddc2256_users u LEFT JOIN ddc2256_groups g ON u.group_id = g.id';
     // Test ResultSetMapping.
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('MyNamespace:DDC2256User', 'u');
     $rsm->addFieldResult('u', 'id', 'id');
     $rsm->addFieldResult('u', 'name', 'name');
     $rsm->addJoinedEntityResult('MyNamespace:DDC2256Group', 'g', 'u', 'group');
     $rsm->addFieldResult('g', 'group_id', 'id');
     $rsm->addFieldResult('g', 'group_name', 'name');
     $this->_em->createNativeQuery($sql, $rsm)->getResult();
     // Test ResultSetMappingBuilder.
     $rsm = new ResultSetMappingBuilder($this->_em);
     $rsm->addRootEntityFromClassMetadata('MyNamespace:DDC2256User', 'u');
     $rsm->addJoinedEntityFromClassMetadata('MyNamespace:DDC2256Group', 'g', 'u', 'group', array('id' => 'group_id', 'name' => 'group_name'));
     $this->_em->createNativeQuery($sql, $rsm)->getResult();
 }
开发者ID:selimcr,项目名称:servigases,代码行数:29,代码来源:DDC2256Test.php

示例3: testQueryNotCacheableAssociationException

 /**
  * @expectedException Doctrine\ORM\Cache\CacheException
  * @expectedExceptionMessage Entity association field "Doctrine\Tests\Models\Cache\City#travels" not configured as part of the second-level cache.
  */
 public function testQueryNotCacheableAssociationException()
 {
     $uow = $this->em->getUnitOfWork();
     $key = new QueryCacheKey('query.key1', 0);
     $rsm = new ResultSetMappingBuilder($this->em);
     $cityClass = $this->em->getClassMetadata(City::CLASSNAME);
     $city = new City("City 1", null);
     $result = array($city);
     $cityClass->setFieldValue($city, 'id', 1);
     $rsm->addRootEntityFromClassMetadata(City::CLASSNAME, 'c');
     $rsm->addJoinedEntityFromClassMetadata(Travel::CLASSNAME, 't', 'c', 'travels', array('id' => 't_id'));
     $uow->registerManaged($city, array('id' => $city->getId()), array('name' => $city->getName(), 'state' => null));
     $this->queryCache->put($key, $rsm, $result);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:18,代码来源:DefaultQueryCacheTest.php


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