제목이 말하는 것을 수행해야합니다.CakePHP의 각 행에 대한 개수가있는 데이터 검색
표시해야하는 특정 쿼리가 있습니다. 원시 쿼리을하고 싶지 않습니다. 내가 만든 다른 쿼리처럼하고 싶습니다. 물론
내가 표시해야 내 데이터베이스 쿼리의 결과입니다
이
내가 내 인덱스에 표시해야하는 결과입니다. 내 사이트에서 동일한 것을 표현해야합니다.다음 방법은 내가 만든 것입니다.
public function index()
{
$country= $this -> Auth -> User()['country_fk'];
$this->paginate['contain'] = ['Dogs','Dogs.Human','Dogs.Human.Cities','Users'];
$this->paginate['conditions'] = ['Users.isHuman' => 0, 'Cities.country_fk' => $country];
$this->paginate['order'] = array('Badges.id' => 'desc');
$badges= $this->paginate($this->Badges);
$this->set(compact('badges'));
$this->set('_serialize', ['badges']);
}
몇 가지 예를 들어 쿼리를 수행 한 후 계산을하지만 난 생각하지 것입니다 :하지만 계산의 부분을 수행하는 방법을 모른다 (내가 쿼리를 완료하는 데 필요한 유일한 부분입니다) 내가 찾고 있어요.
고마워요.
편집 arilia의 대답 후 는, 내 컨트롤러에서 나는 다음과 같은 라인을 가지고 :
<thead>
<tr>
<th><?= $this->Paginator->sort('idBadge', 'ID') ?></th>
<th><?= $this->Paginator->sort('name', 'Name') ?></th>
<th><?= $this->Paginator->sort('value1', 'Value 1') ?></th>
<th><?= $this->Paginator->sort('value2', 'Value 2') ?></th>
<th><?= $this->Paginator->sort('count', 'Quantity') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($badges as $badge): ?>
<tr>
<td><?= h($badge->idBadge) ?></td>
<td><?= h($badge->name) ?></td>
<td><?= h($badge->value1) ?></td>
<td><?= h($badge->value2) ?></td>
<td><?= h($badge->count) ?></td>
</tr>
<?php endforeach; ?>
이 cake2 확실히 당신에게있는 쿼리 빌더이 방법을 사용? 내가 아는 한 cake2는 페이지 매김 호출 후에 객체를 반환하지 않습니다 ... – arilia
죄송합니다, 방금 수정했습니다. 나는 3.0이라고 생각한다. 그것은 오래된 프로젝트이고 케이크의 버전을 잘 기억하지 못했습니다. –