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


PHP ResultSetMapping::addFieldResult方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /** @var ObjectManager $em */
     $em = $this->getContainer()->get('doctrine')->getManager();
     $currentUtc = (new \DateTime())->setTimezone(new \DateTimeZone('UTC'));
     $calculationDate = clone $currentUtc;
     $calculationDate->modify('midnight');
     $systemOffset = (new \DateTime())->getOffset();
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('AcmeUserBundle:User', 'u');
     $rsm->addFieldResult('u', 'id', 'id');
     $rsm->addFieldResult('u', 'timezone', 'timezone');
     $str = 'select u.id as id,
     u.timezone
     from ed_users u
      WHERE DATE_ADD("' . $currentUtc->format('Y-m-d H:i') . '", INTERVAL u.timezone HOUR) > "' . $calculationDate->format('Y-m-d H:i') . '" AND
      NOT EXISTS(SELECT * FROM ed_progress_statistics ps WHERE ps.user_id=u.id AND DATE_ADD(ps.calculated_at, INTERVAL (u.timezone - ' . $systemOffset / 3600 . ') HOUR) > "' . $calculationDate->format('Y-m-d H:i') . '")
     ';
     $query = $em->createNativeQuery($str, $rsm);
     $users = $query->getResult();
     $dayStart = clone $calculationDate;
     $dayStart->sub(new \DateInterval('P1D'));
     $dayFinish = clone $calculationDate;
     foreach ($users as $user) {
         //            $user = $em->find('AcmeUserBundle:User', $user->getId());
         $progress = new ProgressStatistic();
         $progress->setUser($user);
         $queryBuilder = $em->createQueryBuilder();
         $actions = $queryBuilder->from('AcmeEdelaBundle:UserAction', 'ua')->addSelect('uap.result as progress')->addSelect('IDENTITY(a.goal) as goal_id')->leftJoin('AcmeEdelaBundle:Action', 'a', Join::WITH, 'ua.action=a')->leftJoin('AcmeUserBundle:User', 'u', Join::WITH, 'ua.user=u')->leftJoin('AcmeEdelaBundle:UserActionProgress', 'uap', Join::WITH, 'uap.userAction=ua AND
             DATE_ADD2(uap.createdAt, INTERVAL (u.timezone - ' . $systemOffset / 3600 . ')  HOUR) > :dayStart AND
             DATE_ADD2(uap.createdAt, INTERVAL (u.timezone - ' . $systemOffset / 3600 . ')  HOUR) < :dayFinish
             ')->setParameter('dayFinish', $dayFinish)->setParameter('dayStart', $dayStart)->where('ua.user = :user')->setParameter('user', $user);
         $orX = $queryBuilder->expr()->orX();
         $orX->add($queryBuilder->expr()->gt('BIT_AND(ua.periodicity, :dayOfWeek)', '0'));
         $orX->add($queryBuilder->expr()->eq('MOD(DATE_DIFF(ua.createdAt, :date), ua.periodicityInterval)', '0'));
         $actions->andWhere($orX)->setParameter('date', $dayStart)->setParameter('dayOfWeek', (int) (1 << $dayStart->format('w')));
         $actions->andWhere('ua.startAt < :dayFinish');
         var_dump($actions->getQuery()->getSQL(), $dayFinish, $dayStart);
         $actions = $actions->getQuery()->getArrayResult();
         var_dump($actions);
         $progress->setTotalActions(count($actions));
         $progress->setProgressedActions(count(array_filter($actions, function ($item) {
             return (bool) $item['progress'];
         })));
         $goaledActions = count(array_filter($actions, function ($item) {
             return (bool) $item['goal_id'];
         }));
         $progress->setEfficiency($progress->getProgressedActions() * 3 + $goaledActions);
         $em->persist($progress);
     }
     $em->flush();
     $output->writeln('Done');
 }
开发者ID:Alex223124,项目名称:edela,代码行数:53,代码来源:StatisticsCommand.php

示例2: migrateData

 /**
  * Migrate data to plugin database from core table
  *
  * @param EntityManager   $em
  * @param OutputInterface $output
  *
  * @return void
  */
 public function migrateData($em, $output)
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Newscoop\\CommunityTickerBundle\\Entity\\CommunityTickerEvent', 'e');
     $rsm->addFieldResult('e', 'id', 'id');
     $rsm->addFieldResult('e', 'event', 'event');
     $rsm->addFieldResult('e', 'params', 'params');
     $rsm->addFieldResult('e', 'created', 'created');
     $rsm->addJoinedEntityResult('Newscoop\\Entity\\User', 'u', 'e', 'user');
     $rsm->addFieldResult('u', 'Id', 'id');
     $query = $em->createNativeQuery('SELECT e.id, e.event, e.params, e.created, u.Id FROM community_ticker_event e ' . 'LEFT JOIN liveuser_users u ON u.id = e.user_id', $rsm);
     $events = $query->getArrayResult();
     foreach ($events as $key => $event) {
         $user = $em->getRepository('Newscoop\\Entity\\User')->findOneBy(array('id' => $event['user']['id']));
         $existingEvent = $em->getRepository('Newscoop\\CommunityTickerBundle\\Entity\\CommunityTickerEvent')->findOneBy(array('created' => $event['created'], 'params' => $event['params']));
         if (!$existingEvent) {
             $newEvent = new CommunityTickerEvent();
             $newEvent->setEvent($event['event']);
             $newEvent->setParams($event['params'] != '[]' ? json_decode($event['params'], true) : array());
             $newEvent->setCreated($event['created']);
             $newEvent->setIsActive(true);
             if ($user) {
                 $newEvent->setUser($user);
             }
             $em->persist($newEvent);
         }
     }
     $em->flush();
     $output->writeln('<info>Data migrated to plugin table!</info>');
     $output->writeln('<info>Removing old table...</info>');
 }
开发者ID:sourcefabric,项目名称:newscoop,代码行数:39,代码来源:MigrateTablesCommand.php

示例3: getNotasPorPeriodo

 public function getNotasPorPeriodo($periodo, $alumno)
 {
     $planestuRepository = $this->getDoctrine()->getRepository('AppBundle:Planestu');
     $em = $this->getDoctrine()->getManager();
     // Configuracion de la entidad a adoptar la consulta
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('AppBundle:Materias', 'u');
     $rsm->addFieldResult('u', 'cmate', 'cmate');
     $rsm->addFieldResult('u', 'nmate', 'nmate');
     // plan de estudio exceptuando las materias excluidas
     $query = $em->createNativeQuery('SELECT * FROM materias LEFT JOIN planestu 
         ON materias.cmate = planestu.cmate WHERE planestu.cgrupo=? 
         AND materias.cmate NOT IN (SELECT mateexclu.cmate FROM mateexclu WHERE calum =?
         AND (cperi =? OR cperi =?)) ORDER BY orden', $rsm);
     // set parametros al query
     $query->setParameter(1, $alumno->getCgrupo()->getCgrupo());
     $query->setParameter(2, $alumno->getCalum());
     $query->setParameter(3, $periodo);
     $query->setParameter(4, 'T');
     $materias = $query->getResult();
     $notasArray = array();
     foreach ($materias as $materia) {
         $nota = $this->getNota($materia->getCmate(), $alumno->getCalum(), $periodo);
         $notasArray[$materia->getNmate()] = $nota;
     }
     return $notasArray;
 }
开发者ID:stzef,项目名称:siacolweb-app,代码行数:27,代码来源:ConsultarNotasController.php

示例4: testHydrateSingleScalar

 /**
  * select u.name from CmsUser u where u.id = 1
  *
  * @dataProvider singleScalarResultSetProvider
  */
 public function testHydrateSingleScalar($name, $resultSet)
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'u');
     $rsm->addFieldResult('u', 'u__id', 'id');
     $rsm->addFieldResult('u', 'u__name', 'name');
     $stmt = new HydratorMockStatement($resultSet);
     $hydrator = new \Doctrine\ORM\Internal\Hydration\SingleScalarHydrator($this->_em);
     if ($name == 'result1') {
         $result = $hydrator->hydrateAll($stmt, $rsm);
         $this->assertEquals('romanb', $result);
     } else {
         if ($name == 'result2') {
             $result = $hydrator->hydrateAll($stmt, $rsm);
             $this->assertEquals(1, $result);
         } else {
             if ($name == 'result3' || $name == 'result4') {
                 try {
                     $result = $hydrator->hydrateAll($stmt, $rsm);
                     $this->fail();
                 } catch (\Doctrine\ORM\NonUniqueResultException $e) {
                 }
             }
         }
     }
 }
开发者ID:selimcr,项目名称:servigases,代码行数:31,代码来源:SingleScalarHydratorTest.php

示例5: 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

示例6: _getCommonRSM

 private function _getCommonRSM()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('UserBundle:AdminUserRole', 'a');
     $rsm->addFieldResult('a', 'id', 'id');
     $rsm->addFieldResult('a', 'name', 'name');
     $rsm->addFieldResult('a', 'label', 'label');
     $rsm->addFieldResult('a', 'status', 'status');
     return $rsm;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:10,代码来源:AdminUserRoleRepository.php

示例7: getUnassignedUser

 public function getUnassignedUser()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('AppBundle:User', 'u');
     $rsm->addFieldResult('u', 'id', 'id');
     $rsm->addFieldResult('u', 'username', 'username');
     $rsm->addFieldResult('u', 'email', 'email');
     $q = $this->getEntityManager()->createNativeQuery('SELECT u.id, u.username, u.email FROM `user` as u WHERE u.id IN (SELECT getUnassginedUser())', $rsm);
     return $q->getResult();
 }
开发者ID:damiangolojuch,项目名称:taskSystem,代码行数:10,代码来源:UserRepository.php

示例8: getStatistics

 public function getStatistics()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('AppBundle:Stats', 's');
     $rsm->addFieldResult('s', 'player', 'player');
     $rsm->addFieldResult('s', 'win', 'win');
     $rsm->addFieldResult('s', 'lose', 'lose');
     $rsm->addFieldResult('s', 'draw', 'draw');
     $rsm->addFieldResult('s', 'rocks', 'rocks');
     $rsm->addFieldResult('s', 'papers', 'papers');
     $rsm->addFieldResult('s', 'scissors', 'scissors');
     $rsm->addFieldResult('s', 'lizards', 'lizards');
     $rsm->addFieldResult('s', 'spocks', 'spocks');
     $query = $this->_em->createNativeQuery('SELECT
       (SELECT name FROM player WHERE id = player_id) as player,
       SUM(CASE WHEN result = 1 THEN 1 ELSE 0 END ) as win,
       SUM(CASE WHEN result = 0 THEN 1 ELSE 0 END ) as lose,
       SUM(CASE WHEN result = 2 THEN 1 ELSE 0 END ) as draw,
       SUM(CASE WHEN threw = \'Rock\' THEN 1 ELSE 0 END ) as rocks,
       SUM(CASE WHEN threw = \'Paper\' THEN 1 ELSE 0 END ) as papers,
       SUM(CASE WHEN threw = \'Scissors\' THEN 1 ELSE 0 END ) as scissors,
       SUM(CASE WHEN threw = \'Lizard\' THEN 1 ELSE 0 END ) as lizards,
       SUM(CASE WHEN threw = \'Spock\' THEN 1 ELSE 0 END ) as spocks
     FROM stat
     GROUP BY player_id
     ORDER BY player_id', $rsm);
     return $query->getResult();
 }
开发者ID:elinberg,项目名称:bigbang,代码行数:28,代码来源:StatsRepository.php

示例9: getChiefsByOrchestra

 public function getChiefsByOrchestra($codeOrchestra)
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('IUT\\CatalogBundle\\Entity\\Musicien', 'c');
     $rsm->addFieldResult('c', 'Code_Musicien', 'codeMusicien');
     $rsm->addFieldResult('c', 'Nom_Musicien', 'nomMusicien');
     $rsm->addFieldResult('c', 'Prénom_Musicien', 'prénomMusicien');
     $rsm->addFieldResult('c', 'Année_Naissance', 'annéeNaissance');
     $rsm->addFieldResult('c', 'Photo', 'Image');
     return $this->getEntityManager()->createNativeQuery('SELECT DISTINCT c.* FROM Musicien c ' . 'inner join Direction ON c.Code_Musicien = Direction.Code_Musicien ' . 'inner join Orchestres on Direction.Code_Orchestre = Orchestres.Code_Orchestre ' . 'where Orchestres.Code_Orchestre = ? ', $rsm)->setParameter(1, $codeOrchestra)->getResult();
 }
开发者ID:raphael-thibierge,项目名称:ProgWebServerProject,代码行数:11,代码来源:MusicienRepository.php

示例10: getHolidays

 public function getHolidays()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('STX\\CroissantsBundle\\Entity\\Friday_Subscriptions', 'fs');
     $rsm->addFieldResult('fs', 'id', 'id');
     $rsm->addFieldResult('fs', 'date', 'date');
     $rsm->addFieldResult('fs', 'remark', 'remark');
     $sql = 'select fs.id, fs.date, fs.remark' . '	from friday_subscriptions fs ' . '	where fs.date >= NOW() ' . '	AND fs.remark like \'FERIE -%\'' . '	ORDER BY fs.date ASC ';
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $results = $query->getResult();
     return $results;
 }
开发者ID:bionoir,项目名称:stxcroissants,代码行数:12,代码来源:Friday_SubscriptionsRepository.php

示例11: findByExamenId

 /**
  * Returns all competences linked to the specific matiere
  *
  * @param $matiereID
  */
 public function findByExamenId($examenID)
 {
     $sql = "SELECT c.id, c.name " . "FROM c3csi_examen exam " . "LEFT JOIN c3csi_examen_rel_competence exam_comp ON exam_comp.examen_id = exam.id " . "LEFT JOIN c3csi_competence c ON c.id = exam_comp.competence_id " . "WHERE exam.id = ?";
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('SkillBundle\\Entity\\Competence', 'c');
     $rsm->addFieldResult('c', 'id', 'id');
     $rsm->addFieldResult('c', 'name', 'name');
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $query->setParameter(1, $examenID);
     $result = $query->getResult();
     return $result;
 }
开发者ID:jarnal,项目名称:competence_3csi,代码行数:17,代码来源:CompetenceRepository.php

示例12: findByIntervenantId

 /**
  * Returns the examens related to the intervenant passed in parameter
  *
  * @param $intervenantID
  */
 public function findByIntervenantId($intervenantID)
 {
     $sql = "SELECT exam.id, exam.name, exam.description " . "FROM c3csi_user user " . "LEFT JOIN c3csi_examen exam ON exam.intervenant_id = user.id " . "WHERE user.id = ?";
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('EvaluationBundle\\Entity\\Examen', 'm');
     $rsm->addFieldResult('m', 'id', 'id');
     $rsm->addFieldResult('m', 'name', 'name');
     $rsm->addFieldResult('m', 'description', 'description');
     $query = $this->_em->createNativeQuery($sql, $rsm);
     $query->setParameter(1, $intervenantID);
     $result = $query->getResult();
     return $result;
 }
开发者ID:jarnal,项目名称:competence_3csi,代码行数:18,代码来源:EvaluationIntervenantRepository.php

示例13: testMissingDiscriminatorColumnException

 /**
  * @group DDC-1470
  *
  * @expectedException \Doctrine\ORM\Internal\Hydration\HydrationException
  * @expectedExceptionMessage The discriminator column "discr" is missing for "Doctrine\Tests\Models\Company\CompanyPerson" using the DQL alias "p".
  */
 public function testMissingDiscriminatorColumnException()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Doctrine\\Tests\\Models\\Company\\CompanyPerson', 'p');
     $rsm->addFieldResult('p', 'p__id', 'id');
     $rsm->addFieldResult('p', 'p__name', 'name');
     $rsm->addMetaResult('p ', 'discr', 'discr');
     $rsm->setDiscriminatorColumn('p', 'discr');
     $resultSet = array(array('u__id' => '1', 'u__name' => 'Fabio B. Silva'));
     $stmt = new HydratorMockStatement($resultSet);
     $hydrator = new \Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator($this->_em);
     $hydrator->hydrateAll($stmt, $rsm);
 }
开发者ID:davidbui2,项目名称:doctrine2,代码行数:19,代码来源:SimpleObjectHydratorTest.php

示例14: getAlbumsByOrchestra

 public function getAlbumsByOrchestra($codeOrchestra)
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('IUT\\CatalogBundle\\Entity\\Album', 'a');
     $rsm->addFieldResult('a', 'Code_Album', 'codeAlbum');
     $rsm->addFieldResult('a', 'Titre_Album', 'titreAlbum');
     $rsm->addFieldResult('a', 'Année_Album', 'anneeAlbum');
     //$rsm->addFieldResult('a', 'Code_Genre', 'codeGenre');
     // $rsm->addFieldResult('a', 'Code_Editeur', 'codeEditeur');
     $rsm->addFieldResult('a', 'Pochette', 'pochette');
     $rsm->addFieldResult('a', 'ASIN', 'ASIN');
     // build rsm here
     return $this->getEntityManager()->createNativeQuery('SELECT DISTINCT a.* FROM Album a ' . 'inner join Disque ON a.Code_Album = Disque.Code_Album ' . 'inner join Composition_Disque on Disque.Code_Disque = Composition_Disque.Code_Disque ' . 'inner join Enregistrement on Composition_Disque.Code_Morceau = Enregistrement.Code_Morceau ' . 'inner join Direction on Enregistrement.Code_Morceau = Direction.Code_Morceau ' . 'inner join Orchestres on Direction.Code_Orchestre = Orchestres.Code_Orchestre ' . 'where Orchestres.Code_Orchestre = ? ', $rsm)->setParameter(1, $codeOrchestra)->getResult();
 }
开发者ID:raphael-thibierge,项目名称:ProgWebServerProject,代码行数:14,代码来源:AlbumRepository.php

示例15: testSkipUnknownColumns

 /**
  * @group DDC-644
  */
 public function testSkipUnknownColumns()
 {
     $rsm = new ResultSetMapping();
     $rsm->addEntityResult('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'u');
     $rsm->addFieldResult('u', 'u__id', 'id');
     $rsm->addFieldResult('u', 'u__name', 'name');
     $rsm->addScalarResult('foo1', 'foo');
     $rsm->addScalarResult('bar2', 'bar');
     $rsm->addScalarResult('baz3', 'baz');
     $resultSet = array(array('u__id' => '1', 'u__name' => 'romanb', 'foo1' => 'A', 'bar2' => 'B', 'baz3' => 'C', 'foo' => 'bar'));
     $stmt = new HydratorMockStatement($resultSet);
     $hydrator = new \Doctrine\ORM\Internal\Hydration\ScalarHydrator($this->_em);
     $result = $hydrator->hydrateAll($stmt, $rsm);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:17,代码来源:ScalarHydratorTest.php


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