OSCommerce Product Listing Shows Inaccurate Count and Results Per Page
http://www.roguevalleyroses.com/rose_list.php?sea开发者_如何学JAVArch_id=&class=&height=&growth=&color=&bloom_size=&bloom_type=&shade=&fragrance=&disease=&rebloom=þs=&zone=&hybridizer=Ashdown%20Roses&date_range=&text=&view=&show=&page=4
This is the page. The code that queries the results is here: http://pastebin.com/d51bfa53f
I can't make any sense out of how OSCommerce works. Let me know if you need anything else. Also, is this just a common problem in SQL Queries, PHP loops, or in some math being wrong? I am looking to be pointed in the right direction, not necessarily needing an exact answer as this is a hacked/custom OsCommerce.
The problem is in the "group by" clause which the osCommerce code cannot deal with - in the splitResults class file. Struggled with this for a while, and this was my first attempt at fixing it:
if (strpos($sql_query, 'group by')) {
$reviews_count_query = tep_db_query("select count(*) as total from (select count(*)" . substr($sql_query, $pos_from) .") as GroupedResult");
} else {
$reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from)));
}
//$reviews_count_query = tep_db_query("select count(*) as total " . substr($sql_query, $pos_from, ($pos_to - $pos_from)));
However, with further testing, that is not working properly either. I then spent some time working out what was going on exactly, and found similar code already existed in oscommerce at https://github.com/osCommerce/oscommerce2/blob/bda6f6df3e4ab027b72ecfe6a96ac70b6774b312/catalog/admin/stats_customers.php#L40-L45
Here you can see the splitpageresults class is "group by" clause...and then underneath is the "fix" to place the corrected amount of customers into the numrows query. And that query is then appropriated by the splitpageresults to make the "showing x of y results".
I dont think this is spam..
this is a common issue with oscommerce.. esp custom contributions add in for more trouble when it comes to queries.. oscommerce navigation class does not support for use of distinct or group by clauses.. i.e, to say when it counts for the records, it does not consider those keywords.. you would need to modify the split page results class to fix this.
Cheers Shiva
精彩评论