本文整理汇总了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;
}