0
안녕 난 쿼리에서 다음과 같은 결과가 :젠드 DB 얻을
public function getCityCategory($city_id)
{
$select = $this->getDbTable()->getAdapter()->select();
$select->from('business as b', array('b.cat_id'))
->joinInner('business_category as bc','b.cat_id = bc.cat_id',array('bc.cat_name'))
->distinct()
->where('b.city_id='.$city_id);
$result = $this->getDbTable()->getAdapter()->fetchAll($select);
return $result;
}
Array
(
[0] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
[1] => Array
(
[cat_id] => 5
[cat_name] => Arts & Entertainment
)
[2] => Array
(
[cat_id] => 11
[cat_name] => Hotels & Travel
)
[3] => Array
(
[cat_id] => 7
[cat_name] => Nightlife
)
[4] => Array
(
[cat_id] => 20
[cat_name] => Financial Services
)
[5] => Array
(
[cat_id] => 22
[cat_name] => Attractions
)
[6] => Array
(
[cat_id] => 2
[cat_name] => Active Life
)
)
: 나는 다음과 같은 결과를 얻을 수 위의 코드를 별개 추가 할 때
이
public function getCityCategory($city_id)
{
$select = $this->getDbTable()->getAdapter()->select();
$select->from('business as b', array('b.cat_id'))
->joinInner('business_category as bc','b.cat_id = bc.cat_id',array('bc.cat_name'))
->where('b.city_id='.$city_id);
$result = $this->getDbTable()->getAdapter()->fetchAll($select);
return $result;
}
Array
(
[0] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
[1] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
[2] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
[3] => Array
(
[cat_id] => 5
[cat_name] => Arts & Entertainment
)
[4] => Array
(
[cat_id] => 11
[cat_name] => Hotels & Travel
)
[5] => Array
(
[cat_id] => 7
[cat_name] => Nightlife
)
[6] => Array
(
[cat_id] => 20
[cat_name] => Financial Services
)
[7] => Array
(
[cat_id] => 22
[cat_name] => Attractions
)
[8] => Array
(
[cat_id] => 2
[cat_name] => Active Life
)
[9] => Array
(
[cat_id] => 22
[cat_name] => Attractions
)
[10] => Array
(
[cat_id] => 7
[cat_name] => Nightlife
)
[11] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
[12] => Array
(
[cat_id] => 1
[cat_name] => Restaurants
)
)
쿼리는 이제 특정 city_id
에 대한 모든 범주를 반환을
이제 마지막 쿼리에서 개수를 추가하여 중복 된 카테고리를 구분할 수 있으므로 각 카테고리의 비즈니스 총계를 어떻게 얻을 수 있습니까? 그래서 최종 결과는 첫째
찾기 합이
감사 같아야하고 중복 제거 –