View Single Post
Old 06-09-2004, 01:51 AM   #4
synnalagma
Green Mole
 
Join Date: Mar 2004
Posts: 22
This don't work because ordering is done on the php code and not on the database.

Try the following :
Install the mod I've submitted : Optimized Search
In queryparser.php around line 100 change
PHP Code:
$usetspider=false
to
PHP Code:
$usetspider=true
In queryparser.php around line 126

PHP Code:
$this->sql="SELECT $tengine.spider_id, SUM($tengine.weight) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")." $tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).") $spiderquery GROUP BY $tengine.spider_id ".($operatorhaving!=""?"HAVING $operatorhaving ":"")."ORDER BY w DESC"
and change it to :

PHP Code:
$this->sql="SELECT $tengine.spider_id, SUM($tengine.weight) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")." $tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).") $spiderquery GROUP BY $tengine.spider_id ".($operatorhaving!=""?"HAVING $operatorhaving ":"")."ORDER BY $tspider.last_modified, w DESC"
Also change around line 140

PHP Code:
$this->sql.=" END)) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")."$tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).")  $spiderquery GROUP BY $tengine.spider_id HAVING w>0".($operatorhaving!=""?" AND $operatorhaving ":"")." ORDER BY w DESC"
to

PHP Code:
$this->sql.=" END)) AS w $operatorquery FROM ".($usetspider?"$tspider, ":"")."$tengine WHERE $tengine.key_id IN (".implode(',',$this->wordsid).")  $spiderquery GROUP BY $tengine.spider_id HAVING w>0".($operatorhaving!=""?" AND $operatorhaving ":"")." ORDER BY $tspider.last_modified, w DESC"
This should sort results by last modified and by results weight if two results have the same date.

Note I didn't tested it but it should work
synnalagma is offline   Reply With Quote