1
我從這個查詢Zend_Paginator_Adapter_DbTableSelect對象:循環訪問Zend_Paginator的對象顯示
public function fetchPagedTracks() {
$select = $this->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
->setIntegrityCheck(FALSE);
$select->join(array('ar' => 'artist'), 'ar.id = track.artist_id',
array('artist_name' => 'name'));
$select->join(array('al' => 'album'), 'al.id = track.album_id',
array('album_name' => 'name', 'artist_id', 'year'));
$select->order('artist_name', 'ASC');
$select->order('album_name');
$select->order('track', 'ASC');
//create a new instance of the paginator adapter and return it
$adapter = new Zend_Paginator_Adapter_DbTableSelect($select);
return $adapter;
}
預期和工程數據的回報,我的問題是我viewscript。我想以特定的方式迭代結果集。基本上我想讓藝術家在每張專輯的子表格的頂部,並列出每首專輯的順序。我已經完成了這個......但不正確,我不得不做我覺得是黑客,我希望能夠幫助我解決它。
這裏是視圖:
<?php
echo $this->paginationControl(
$this->paginator, 'Sliding', '_paginatorControl.phtml'
)
?>
<table>
<?php
foreach ($this->paginator as $track):;
// Zend_Debug::dump($track, '');
$artist = $track->artist_name;
$album = $track->album_name;
?>
<?php if ($end_artist != $artist): ?>
<tr>
<th colspan="4"><?php echo $track->artist_name ?></th>
</tr>
<?php endif ?>
<?php if ($end_album != $album): ?>
<tr>
<th colspan="4"><?php echo $track->album_name . ' ' . $track->year ?></th>
</tr>
<tr>
<th>Track #</th>
<th>Title</th>
<th>Bitrate</th>
<th>Play Time</th>
</tr>
<?php endif; ?>
<tr>
<td><?php echo $track->track ?></td>
<td><?php echo $track->title ?></td>
<td><?php echo $track->bit_rate . 'Kbps' ?></td>
<td><?php echo $this->playtime($track->play_time) ?></td>
</tr>
<?php
$end_artist = $track->artist_name;
$end_album = $track->album_name
?>
<?php endforeach ?>
</table>
<?php
echo $this->paginationControl(
$this->paginator, 'Sliding', '_paginatorControl.phtml'
); ?>
最大的問題是,這種代碼會導致兩個公告:
注意:未定義的變量:end_artist在 E:\ WWW \ home.local \程序\模塊\音樂\意見\腳本\首頁\ display.phtml 上線13 ...和第18行
有問題的變量是$end_artist
和$end_album
對於我來說,我無法弄清楚如何以不同的方式做到這一點。建議?
P.S.該分頁程序對象的轉儲可以在Pastbin
之前,我確實說:「哦,大壩!」 ......講座關於缺少明顯的感謝。 – RockyFord 2012-03-17 23:14:26