From 8abeeaf65e79a464aae6d40f8868ecd29889df4c Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 16 Dec 2013 17:45:57 +0100 Subject: SQL : correction recherche MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oups, mon précédent changement SQL avait cassé la recherche. Patch rapide en attendant une ré-optimisation en particulier pour le cas de recherche sur plusieurs mots --- app/Models/EntryDAO.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 5a34573db..c4eb0a84a 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -311,14 +311,14 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { } $terms = array_unique(explode(' ', trim($filter))); sort($terms); //Put #tags first - $having = ''; + $search = ''; foreach ($terms as $word) { if (!empty($word)) { if ($word[0] === '#' && isset($word[1])) { - $having .= 'AND e1.tags LIKE ? '; + $search .= 'AND e1.tags LIKE ? '; $values[] = '%' . $word .'%'; } elseif (!empty($word)) { - $having .= 'AND (e1.title LIKE ? OR content LIKE ?) '; + $search .= 'AND (e1.title LIKE ? OR UNCOMPRESS(e1.content_bin) LIKE ?) '; $values[] = '%' . $word .'%'; $values[] = '%' . $word .'%'; } @@ -330,7 +330,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { . 'INNER JOIN (SELECT e1.id FROM `' . $this->prefix . 'entry` e1 ' . ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e1.id_feed = f.id ' : '') . 'WHERE ' . $where - . (empty($having) ? '' : 'HAVING' . substr($having, 3)) + . $search . 'ORDER BY e1.id ' . $order . ($limit > 0 ? ' LIMIT ' . $limit : '') //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ . ') e2 ON e2.id = e.id ' -- cgit v1.2.3