summaryrefslogtreecommitdiff
path: root/modules/search/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2013-02-15 13:00:26 -0500
committerBharat Mediratta <bharat@menalto.com>2013-02-15 13:00:26 -0500
commit96a01c86d9bd15f9dc91c60be6f236deab2ffad9 (patch)
treedb06b9a5ab2b03a0475f536b9792435059f999e9 /modules/search/helpers
parent16b8b8d16b8b46fe1e60b2a86f9ee5883dbc892f (diff)
parent5b6c138da1e53e93e4de8079885fcef29d12e673 (diff)
Merge branch 'master' into jquery_190
Diffstat (limited to 'modules/search/helpers')
-rw-r--r--modules/search/helpers/search.php10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php
index b1bde359..b21e59dd 100644
--- a/modules/search/helpers/search.php
+++ b/modules/search/helpers/search.php
@@ -132,11 +132,12 @@ class search_Core {
static function get_position_within_album($item, $q, $album) {
$page_size = module::get_var("gallery", "page_size", 9);
- $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id));
+ $query = self::_build_query_base($q, $album, array("{items}.id = " . $item->id)) .
+ "ORDER BY `score` DESC ";
$db = Database::instance();
// Truncate the score by two decimal places as this resolves the issues
- // that arise due to in exact numeric conversions.
+ // that arise due to inexact numeric conversions.
$current = $db->query($query)->current();
if (!$current) {
// We can't find this result in our result set - perhaps we've fallen out of context? Clear
@@ -149,7 +150,10 @@ class search_Core {
$score = substr($score, 0, strlen($score) - 2);
}
- $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score);
+ // Redo the query but only look for results greater than or equal to our current location
+ // then seek backwards until we find our item.
+ $data = $db->query(self::_build_query_base($q, $album) . " HAVING `score` >= " . $score .
+ "ORDER BY `score` DESC ");
$data->seek($data->count() - 1);
while ($data->get("id") != $item->id && $data->prev()->valid()) {