好的,这是我的分页代码:
$SQL = "SELECT
cpc.product_id,
cp.product_internal_ref,
cp.product_name,
cpa.product_sale_price,
cpa.is_product_service,
cpa.product_service_price,
cpi.image_name,
cpi.image_ext
FROM catalog_products_categories cpc
JOIN catalog_products cp ON cp.product_id = cpc.product_id
JOIN catalog_products_attributes cpa ON cpa.product_id = cpc.product_id
LEFT JOIN catalog_products_images cpi ON cpi.product_id = cpc.product_id
WHERE cpc.category_id = ".$catID;
// PAGINATOR SECTION
if($paginatorVARS['paginatorACTION'] == "next") {
$SQL .= " AND cpc.product_id > ".$paginatorVARS['paginatorGOID']." ";
$SQL .= "GROUP BY cpc.product_id ORDER BY cpc.product_id ASC LIMIT ".$paginatorVARS['catalogPaginatorPAGEROWS'];
}
elseif($paginatorVARS['paginatorACTION'] == "prev") {
$SQL .= " AND cpc.product_id < ".$paginatorVARS['paginatorGOID']." ";
$SQL .= "GROUP BY cpc.product_id ORDER BY cpc.product_id DESC LIMIT ".$paginatorVARS['catalogPaginatorPAGEROWS'];
}
// END PAGINATOR SECTION
我使用了这里描述的方法:http : //www.slideshare.net/Eweaver/efficient-pagination-using-mysql 但我无法找到一种方法来按其他列排序,例如按 cpa.product_sale_price。如果我这样做:按 cpc.product_id ASC 订购,cpa.product_sale_price DESC/ASC 它会破坏分页器下一个结果我不知道会发生什么...请帮助!