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


PHP Query::getArrayResult方法代码示例

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


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

示例1: getList

 /**
  * Get list of values.
  *
  * @access   public
  * @param    string $sKey
  * @param    string $sValue
  * @return   array
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function getList($sKey, $sValue)
 {
     static::$mResult = $this->oQuery->getArrayResult();
     $aResults = [];
     foreach (static::$mResult as $mResult) {
         $aResults[$mResult[$sKey]] = $mResult[$sValue];
     }
     return $aResults;
 }
开发者ID:ktrzos,项目名称:plethora,代码行数:19,代码来源:DB.php

示例2: processMostSearchedQuery

 /**
  * @param Query $query
  *
  * @return array
  */
 protected function processMostSearchedQuery(Query $query)
 {
     $resultQuery = $query->getArrayResult();
     $result = [];
     foreach ($resultQuery as $answerArray) {
         $result[] = ['title' => $answerArray['title'], 'description' => $answerArray['description'], 'uri' => $this->routerInterface->generate('aalto_api_answer_show', ['slug' => $answerArray['slug']])];
     }
     return $result;
 }
开发者ID:Neirda24,项目名称:Aalto,代码行数:14,代码来源:AnswerManager.php

示例3: testDqlFunction

 /**
  * @dataProvider functionsDataProvider
  * @param array $functions
  * @param string $dql
  * @param string $sql
  * @param string $expectedResult
  */
 public function testDqlFunction(array $functions, $dql, $sql, $expectedResult)
 {
     $configuration = $this->entityManager->getConfiguration();
     foreach ($functions as $function) {
         $this->registerDqlFunction($function['type'], $function['name'], $function['className'], $configuration);
     }
     $query = new Query($this->entityManager);
     $query->setDQL($dql);
     $this->assertEquals($sql, $query->getSQL(), sprintf('Unexpected SQL for "%s"', $dql));
     $result = $query->getArrayResult();
     $this->assertNotEmpty($result);
     $this->assertEquals($expectedResult, array_values(array_shift($result)), sprintf('Unexpected result for "%s"', $dql));
 }
开发者ID:sergeypererva,项目名称:doctrine-extensions,代码行数:20,代码来源:FunctionsTest.php

示例4: paginate

 /**
  * {@inheritdoc}
  */
 public function paginate(Query $query, $results, $offset, $arrayResult = true)
 {
     if ($results <= 0 || $results > $this->maxResults) {
         $results = $this->defaultResults;
     }
     if ($offset < 0) {
         $offset = 0;
     }
     $paginator = new Paginator($query, false);
     $query->setFirstResult($offset)->setMaxResults($results);
     if ($arrayResult) {
         $result = $query->getArrayResult();
     } else {
         $result = $query->getResult();
     }
     return ['recordsTotal' => count($paginator), 'recordsFiltered' => count($paginator), 'data' => $result];
 }
开发者ID:mangati,项目名称:base-bundle,代码行数:20,代码来源:DataTables.php

示例5: testDateFunction

 /**
  * @dataProvider functionsDataProvider
  * @param string $type
  * @param string $functionName
  * @param string $functionClass
  * @param string $dql
  * @param string $sql
  * @param string $expectedResult
  */
 public function testDateFunction($type, $functionName, $functionClass, $dql, $sql, $expectedResult)
 {
     $configuration = $this->entityManager->getConfiguration();
     switch ($type) {
         case 'datetime':
             $configuration->addCustomDatetimeFunction($functionName, $functionClass);
             break;
         case 'numeric':
             $configuration->addCustomNumericFunction($functionName, $functionClass);
             break;
         case 'string':
         default:
             $configuration->addCustomStringFunction($functionName, $functionClass);
     }
     $query = new Query($this->entityManager);
     $query->setDQL($dql);
     $this->assertEquals($sql, $query->getSQL(), sprintf('Unexpected SQL for "%s"', $dql));
     $result = $query->getArrayResult();
     $this->assertNotEmpty($result);
     $this->assertEquals($expectedResult, array_values(array_shift($result)), sprintf('Unexpected result for "%s"', $dql));
 }
开发者ID:sergeyz,项目名称:doctrine-extensions,代码行数:30,代码来源:FunctionsTest.php

示例6: normalize

 /**
  * @inheritdoc
  */
 public function normalize(Query $query, QueryBuilder $queryBuilder)
 {
     // execute the query
     $itemList = $query->getArrayResult();
     // normalize result (for request of type $queryBuilder->select("item, bp, item.id * 3 as titi"); )
     $normalizedItemList = array();
     foreach ($itemList as $item) {
         $normalizedItem = array();
         foreach ($item as $key => $val) {
             // hack : is_array is added according to this issue : https://github.com/kitpages/KitpagesDataGridBundle/issues/18
             // can't reproduce this error...
             if (is_int($key) && is_array($val)) {
                 foreach ($val as $newKey => $newVal) {
                     $normalizedItem[$newKey] = $newVal;
                 }
             } else {
                 $normalizedItem[$key] = $val;
             }
         }
         $normalizedItemList[] = $normalizedItem;
     }
     return $normalizedItemList;
 }
开发者ID:mops1k,项目名称:KitpagesDataGridBundle,代码行数:26,代码来源:LegacyNormalizer.php

示例7: testDqlFunction

 /**
  * @dataProvider functionsDataProvider
  * @param array $functions
  * @param string $dql
  * @param string $sql
  * @param string $expectedResult
  */
 public function testDqlFunction(array $functions, $dql, $sql, $expectedResult)
 {
     $configuration = $this->entityManager->getConfiguration();
     foreach ($functions as $function) {
         $this->registerDqlFunction($function['type'], $function['name'], $function['className'], $configuration);
     }
     $query = new Query($this->entityManager);
     $query->setDQL($dql);
     if (is_array($sql)) {
         $constraints = array();
         foreach ($sql as $sqlVariant) {
             $constraints[] = $this->equalTo($sqlVariant);
         }
         $constraint = new \PHPUnit_Framework_Constraint_Or();
         $constraint->setConstraints($constraints);
         $this->assertThat($query->getSQL(), $constraint);
     } else {
         $this->assertEquals($sql, $query->getSQL(), sprintf('Unexpected SQL for "%s"', $dql));
     }
     $result = $query->getArrayResult();
     $this->assertNotEmpty($result);
     $this->assertEquals($expectedResult, array_values(array_shift($result)), sprintf('Unexpected result for "%s"', $dql));
 }
开发者ID:sblmasta,项目名称:doctrine-extensions,代码行数:30,代码来源:FunctionsTest.php

示例8: formatDate

 /**
  * @param Query  $query
  * @param string $dateFormat
  *
  * @return array
  */
 private function formatDate(Query $query, $dateFormat = 'Y-m-d')
 {
     $payments = [];
     foreach ($query->getArrayResult() as $result) {
         /** @var \DateTime $created */
         $created = $result['created'];
         $date = $created->format($dateFormat);
         if (!isset($payments[$date])) {
             $payments[$date] = 0;
         }
         $payments[$date] += $result['totalAmount'];
     }
     return $payments;
 }
开发者ID:csbill,项目名称:csbill,代码行数:20,代码来源:PaymentRepository.php

示例9: getResult

 /**
  * Processes the result after it was retrieved. In the default configuration, it returns an array result, or
  * if no query fields are specified, it tries to serialize all objects.
  */
 protected function getResult(Query $query)
 {
     if (count($this->getQueryFields()) == 0) {
         $aSerializedResult = array();
         foreach ($query->getResult() as $result) {
             $aSerializedResult[] = $result->serialize();
         }
         return $aSerializedResult;
     } else {
         return $query->getArrayResult();
     }
 }
开发者ID:JohnEffland,项目名称:PartKeepr,代码行数:16,代码来源:AbstractManager.php

示例10: getFlatTreeByQuery

 public function getFlatTreeByQuery(AbstractTreeRepository $repository, \Doctrine\ORM\Query $query)
 {
     return $repository->buildTreeArray($query->getArrayResult());
 }
开发者ID:RSSfeed,项目名称:AdminBundle,代码行数:4,代码来源:Tree.php

示例11: doQueryResult

 public static function doQueryResult(\Doctrine\ORM\Query $query, $resultType)
 {
     switch ($resultType) {
         case ResultType::ArrayType:
             return $query->getArrayResult();
             break;
         case ResultType::ObjectType:
             return $query->getResult();
             break;
         case ResultType::SingleObjectType:
             return $query->getSingleResult();
             break;
         case ResultType::SingleArrayType:
             return $query->getSingleResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
             break;
         default:
             throw new \Exception("Not a valid ResultType.");
     }
 }
开发者ID:jjspider277,项目名称:weddings,代码行数:19,代码来源:UtilRepository2.php


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