我遇到了分页问题。 这是我的代码:
<?php foreach($paginator->items as $key => $item): if(empty($item->getTvguide($params)->toArray())) continue; ?>
<div class="col-md-6">
<div class="channel">
<div class="channel-img pull-left">
<img src="<?=$item->icon?>" alt="publica">
</div>
<div class="clearfix channel-name">
<h3><?=$item->title?></h3>
</div>
<div class="clearfix channel-program">
<ul>
<?php foreach($item->getTvguide($params)->toArray() as $val): ?>
<li><span><?=$val['time']?></span> <?=$val['prog']?></li>
<?php endforeach; ?>
</ul>
</div>
</div>
</div>
<?php endforeach; ?>
当循环继续if(空...)时,我在页面上得到空结果。如何在第一页上获得结果并在分页时删除空结果?
代码控制器:
$data = TvguideChannel::find();
$paginator = new PaginatorModel(
array(
"data" => $data,
"limit" => $limit,
"page" => $curPage
)
);
$params = [
'columns' => 'distinct(time) as time, prog',
'conditions' => $this->getType($this->request->get('type')) . ' AND ' . $this->getDay($this->request->get('day')) . ' AND ' . 'id_group = 13',
'order' => 'time ASC'
];
$items= $paginator->getPaginate();
答案 0 :(得分:0)
$data = TvguideChannel::find([
'conditions' => $this->getType($this->request->get('type')) . ' AND ' . $this->getDay($this->request->get('day')) . ' AND ' . 'id_group = 13',
'columns' => 'distinct(time) as time, prog',
'limit' => $limit,
'offset' => $curPage,
'order' => 'time ASC'
]);
这样的事情,不要忘记消毒你的状况。