查询第3,4条数据
select top 5 * from article where id not in(select top 2 id from article )
SELECT * FROM article where {$sql_fix} order by id desclimit 0,12
public function getAll($sql){
if(preg_match("/limit/i",$sql)){
$sql=str_ireplace("limit","limit",$sql);
$limit=explode("limit",$sql);
$sqlNew=$limit[0];
$page=explode(",",$limit[1]);
$pageStart=intval($page[0]);
$pageEnd=intval($page[1]);
$where=" 1=1 ";
if(preg_match("/where/i",$sqlNew)){
$sqlWhere=str_ireplace("where","where",$sqlNew);
$sqlWhere=explode("where",$sqlWhere);
$sqlNew=$sqlWhere[0];
$where=$sqlWhere[1];
}
$sqlNewDo=str_ireplace("SELECT","SELECT top {$pageEnd}",$sqlNew);
$sqlSonDo=str_ireplace(array("SELECT","*"),array("SELECT top {$pageStart}","id"),$sqlNew);
$sql=$sqlNewDo." where id not in({$sqlSonDo}) and ".$where;
//echo $sql;
}
$result = $this->query($sql);
$arr=array();
while($row= sqlsrv_fetch_array($result))
{
$arr[]=$row;
}
return $arr;
}