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


PHP EntityRepository::findAllByCity方法代码示例

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


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

示例1: searchLocalAuthor

 /**
  * search local authors based of the parameters and filters given
  * @param array $params  []
  * @param array $filters []
  *
  * @return array
  */
 public function searchLocalAuthor($params, $filters)
 {
     $city = isset($params['city']) ? $params['city'] : 0;
     $country = isset($params['country']) ? $params['country'] : 0;
     $name = isset($filters['name']) ? $filters['name'] : '';
     $page = isset($filters['page']) ? $filters['page'] : 1;
     $limit = isset($filters['limit']) ? $filters['limit'] : 0;
     $search = array();
     //search all
     if ($country == 0 && $city == 0) {
         $data = $this->repository->findAllWithFilters($limit, ($page - 1) * $limit, $name);
         $totalCount = count($data);
         $search = array('count' => $totalCount, 'result' => $data);
     } else {
         if ($country > 0 && $city == 0) {
             //search by country
             $this->setRepository('BugglMainBundle:Location');
             $data = $this->repository->findAllByCountry($country, $limit, ($page - 1) * $limit, $name);
             $totalCount = count($data);
             $authors = array();
             foreach ($data as $each) {
                 $authors[] = $each->getLocalAuthor();
             }
             $search = array('count' => $totalCount, 'result' => $authors);
         } else {
             if ($country > 0 && $city > 0) {
                 //search by  city
                 $this->setRepository('BugglMainBundle:Location');
                 $data = $this->repository->findAllByCity($city, $limit, ($page - 1) * $limit, $name);
                 $totalCount = count($data);
                 $authors = array();
                 foreach ($data as $each) {
                     $authors[] = $each->getLocalAuthor();
                 }
                 $search = array('count' => $totalCount, 'result' => $authors);
             }
         }
     }
     return $search;
 }
开发者ID:thebuggl-org,项目名称:tests-buggl,代码行数:47,代码来源:BugglSearchLocalAuthor.php


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