From 668323434d4de425bf220abee829ae7687350a32 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 24 Jan 2011 13:59:22 +0000 Subject: [PATCH] Start another attack on raw sql queries --- includes/search/SearchMySQL.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/includes/search/SearchMySQL.php b/includes/search/SearchMySQL.php index b92682adf2..b75f116dd2 100644 --- a/includes/search/SearchMySQL.php +++ b/includes/search/SearchMySQL.php @@ -196,7 +196,7 @@ class SearchMySQL extends SearchEngine { if( $this->showRedirects ) { return ''; } else { - return 'AND page_is_redirect=0'; + return 'page_is_redirect=0'; } } @@ -212,7 +212,7 @@ class SearchMySQL extends SearchEngine { } else { $namespaces = $this->db->makeList( $this->namespaces ); } - return 'AND page_namespace IN (' . $namespaces . ')'; + return 'page_namespace IN (' . $namespaces . ')'; } /** @@ -240,8 +240,8 @@ class SearchMySQL extends SearchEngine { */ function getQuery( $filteredTerm, $fulltext ) { return $this->queryMain( $filteredTerm, $fulltext ) . ' ' . - $this->queryRedirect() . ' ' . - $this->queryNamespaces() . ' ' . + 'AND ' . $this->queryRedirect() . ' ' . + 'AND ' . $this->queryNamespaces() . ' ' . $this->queryRanking( $filteredTerm, $fulltext ) . ' ' . $this->queryLimit(); } @@ -276,13 +276,15 @@ class SearchMySQL extends SearchEngine { function getCountQuery( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); - $page = $this->db->tableName( 'page' ); - $searchindex = $this->db->tableName( 'searchindex' ); - return "SELECT COUNT(*) AS c " . - "FROM $page,$searchindex " . - 'WHERE page_id=si_page AND ' . $match . - $this->queryRedirect() . ' ' . - $this->queryNamespaces(); + + return $this->db->selectSQLText( array( 'page', 'searchindex' ), + 'COUNT(*) AS c', + array( + 'page_id=si_page', + $match, + $this->queryRedirect(), + $this->queryNamespaces() + ) ); } /** -- 2.20.1