【发布时间】:2015-11-28 13:05:00
【问题描述】:
我目前在“汽车类”中有一个显示汽车的方法:
static function getCars(){
$autos = DB::query("SELECT * FROM automoviles");
$retorno = array();
foreach($autos as $a){
$automovil = automovil::fromDB($a->marca, $a->modelo, $a->version, $a->year, $a->usuario_id, $a->kilometraje, $a->info,
$a->hits, $a->cilindrada, $a->estado, $a->color, $a->categoria, $a->precio, $a->idAutomovil);
array_push($retorno, $automovil);
}
return $retorno;
}
在我的 index.php 中,我调用了该函数
foreach(car::getCars() as $a){
这允许我以这种方式显示信息(当然在 foreach 中我有一个巨大的代码,其中包含我将显示的详细信息。
有没有办法实现对那个东西的分页,这样我每页可以处理 8 辆汽车,而不是在同一页面上显示所有汽车?
【问题讨论】:
-
你在使用任何框架吗?我不确定 DB::select 是什么?
标签: php pagination