155 文字
1 分
CakePHP1.2でPaginate
以下に、簡単にやり方をまとめておく。
Controllerへ、以下を追加。ModelからDBへアクセスしないで、Controllerのメソッドを経由して間接的にModelを呼ぶ。
$this->set('customers', $this->paginate('Customer'));Viewへ以下を追加。
Showing Page <?php echo $paginator->counter(); ?><table> <tr> <th><?php echo $paginator->sort('Customer Name', 'name');?></th> <th><?php echo $paginator->sort('Store Location', 'store');?></th> </tr><?php foreach($customers as $customer): ?> <tr> <td><?php echo $customer['Customer']['name']; ?></td> <td><?php echo $customer['Customer']['store']; ?></td> </tr><?php endforeach; ?></table><?php echo $paginator->prev(); ?><?php echo $paginator->numbers(); ?><?php echo $paginator->next(); ?>1.xの時代からはかなり整理された。
CakePHP1.2でPaginate
https://blog.teraren.com/posts/cakephp12でpaginate/