저는 PHP 세계에서오고 있습니다. 레코드 집계를해야합니다. PHP에서 나는 나에게Groovy의 연관 배열과 같은 PHP
['5-15']['foo'] = 1
['5-15']['bar'] = 1
['5-16']['foo'] = 1
['5-17']['foo'] = 2
['5-17']['bar'] = 2
로그 실제로 GORM 쿼리에서 반환 된 내 결과 집합은 결과를 제공
$logs = array(array('date' => '5-15', 'name' => 'foo' ...other stuff),
array('date' => '5-15', 'name' => 'bar' ...other stuff),
array('date' => '5-16', 'name' => 'foo' ...other stuff),
array('date' => '5-17', 'name' => 'foo' ...other stuff),
array('date' => '5-17', 'name' => 'foo' ...other stuff),
array('date' => '5-17', 'name' => 'bar' ...other stuff),
array('date' => '5-17', 'name' => 'bar' ...other stuff));
$counts = array();
foreach($logs as $log) {
if(isset($counts[ $log['date'] ][ $log['name'] ])) {
$counts[ $log['date'] ][ $log['name'] ] = 1;
} else {
$counts[ $log['date'] ][ $log['name'] ]++;
}
}
그루비
에서 다음이 간단 알고 있지만 어떻게합니까.
시험이 내가하려고 할 때 작동하고 때 나는 예상대로 정확히 모든 값을 포함하는 객체를 인쇄 로그 디버깅하지만, 지도에서 특정 값을 얻으려면 NULL이 표시됩니다. –
@BDKosher가 사용했던 나의 친애하는 친구와 동일한 주장을 시도해보십시오. 내 업데이 트를 참조하십시오. – dmahapatro
@MikeLP 잘 보입니까? – dmahapatro