diff options
Diffstat (limited to 'modules/search/helpers')
| -rw-r--r-- | modules/search/helpers/search.php | 6 | ||||
| -rw-r--r-- | modules/search/helpers/search_installer.php | 23 | 
2 files changed, 13 insertions, 16 deletions
| diff --git a/modules/search/helpers/search.php b/modules/search/helpers/search.php index 15efa3b2..ea8dad81 100644 --- a/modules/search/helpers/search.php +++ b/modules/search/helpers/search.php @@ -34,18 +34,18 @@ class search_Core {      // Count the total number of rows.  We can't do this with our regular query because of the      // limit statement.  It's possible that if we get rid of the limit (but keep the offset) on      // the 2nd query and combine the two, it might be faster than making 2 separate queries. -    $count_query = "SELECT COUNT(*) AS C " . +    $count_query = "SELECT COUNT(*) AS c " .        "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " .        "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " .        $access_sql; -    $count = $db->query($count_query)->current()->C; +    $count = $db->query($count_query)->current()->c;      $query = "SELECT {items}.*, MATCH({search_records}.`data`) AGAINST ('$q') AS `score` " .        "FROM {items} JOIN {search_records} ON ({items}.`id` = {search_records}.`item_id`) " .        "WHERE MATCH({search_records}.`data`) AGAINST ('$q' IN BOOLEAN MODE) " .        $access_sql .        "ORDER BY `score` DESC " . -      "LIMIT $offset, $limit"; +      "LIMIT $limit OFFSET $offset";      return array($count, new ORM_Iterator(ORM::factory("item"), $db->query($query)));    } diff --git a/modules/search/helpers/search_installer.php b/modules/search/helpers/search_installer.php index ed4a3a90..cd253be4 100644 --- a/modules/search/helpers/search_installer.php +++ b/modules/search/helpers/search_installer.php @@ -19,20 +19,17 @@   */  class search_installer {    static function install() { -    $version = module::get_version("search");      $db = Database::instance(); -    if ($version == 0) { -      $db->query("CREATE TABLE {search_records} ( -                   `id` int(9) NOT NULL auto_increment, -                   `item_id` int(9), -                   `dirty` boolean default 1, -                   `data` LONGTEXT default NULL, -                   PRIMARY KEY (`id`), -                   KEY(`item_id`), -                   FULLTEXT INDEX (`data`)) -                 ENGINE=MyISAM DEFAULT CHARSET=utf8;"); -      module::set_version("search", 1); -    } +    $db->query("CREATE TABLE {search_records} ( +                 `id` int(9) NOT NULL auto_increment, +                 `item_id` int(9), +                 `dirty` boolean default 1, +                 `data` LONGTEXT default NULL, +                 PRIMARY KEY (`id`), +                 KEY(`item_id`), +                 FULLTEXT INDEX (`data`)) +               ENGINE=MyISAM DEFAULT CHARSET=utf8;"); +    module::set_version("search", 1);    }    static function activate() { | 
