今天有个技术群里有人问到这个问题。
把一年多前做的sql语句拿出来献丑了,抛砖引玉,有更好的方法欢迎交流。
$where="WHERE USERID='$userId'";
$orderBy ="ORDER BY ID desc";
$totalNum=$this->favoritesTotal($userId);
if($curPage <= 0 || $curPage > ceil($totalNum / $PerPageNum)){
$curPage = 1;
}
$rowBegin=$PerPageNum*($curPage-1)+1;
$rowEnd = $curPage*$PerPageNum;
$sqlList="select * from (select rownum row_num,a.* from (select infoid,
infotype,to_char(INFOTIME,'yyyy-mm-dd') INFOTIME,infoname,id,tablename
from favorite $where $orderBy) a)where row_num between
$rowBegin and $rowEnd";