[pLog-svn] r4682 - plog/branches/lifetype-1.2/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Sat Feb 3 07:37:08 EST 2007
Author: oscar
Date: 2007-02-03 07:37:08 -0500 (Sat, 03 Feb 2007)
New Revision: 4682
Modified:
plog/branches/lifetype-1.2/class/dao/articles.class.php
Log:
Added a fastpath via FULLTEXT for articles
Modified: plog/branches/lifetype-1.2/class/dao/articles.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/dao/articles.class.php 2007-02-03 11:55:37 UTC (rev 4681)
+++ plog/branches/lifetype-1.2/class/dao/articles.class.php 2007-02-03 12:37:08 UTC (rev 4682)
@@ -295,27 +295,34 @@
lt_include( PLOG_CLASS_PATH."class/dao/searchengine.class.php" );
$searchTerms = SearchEngine::adaptSearchString( $searchTerms );
- // Split the search term by space
- $query_array = explode(' ', $searchTerms);
+ $db =& Db::getDb();
+ if( $db->isFullTextSupported()) {
+ // fastpath when FULLTEXT is supported
+ $whereString = " MATCH(normalized_text, normalized_topic) AGAINST ('{$searchTerms}' IN BOOLEAN MODE)";
+ }
+ else {
+ // Split the search term by space
+ $query_array = explode(' ', $searchTerms);
- // For each search terms, I should make a like query for it
- $whereString = "(";
- $whereString .= "((normalized_topic LIKE '%{$query_array[0]}%') OR (normalized_text LIKE '%{$query_array[0]}%'))";
- for ( $i = 1; $i < count($query_array); $i = $i + 1) {
+ // For each search terms, I should make a like query for it
+ $whereString = "(";
+ $whereString .= "((normalized_topic LIKE '%{$query_array[0]}%') OR (normalized_text LIKE '%{$query_array[0]}%'))";
+ for ( $i = 1; $i < count($query_array); $i = $i + 1) {
- $whereString .= " AND ((normalized_topic LIKE '%{$query_array[$i]}%') OR (normalized_text LIKE '%{$query_array[$i]}%'))";
- }
- $whereString .= " OR ((normalized_topic LIKE '%{$searchTerms}%') OR (normalized_text LIKE '%{$searchTerms}%'))";
- $whereString .= ")";
-
+ $whereString .= " AND ((normalized_topic LIKE '%{$query_array[$i]}%') OR (normalized_text LIKE '%{$query_array[$i]}%'))";
+ }
+ $whereString .= " OR ((normalized_topic LIKE '%{$searchTerms}%') OR (normalized_text LIKE '%{$searchTerms}%'))";
+ $whereString .= ")";
+ }
+
$query = "SELECT article_id FROM ".$this->getPrefix()."articles_text
- WHERE $whereString";
+ WHERE $whereString";
// execute the query and process the result if any
$result = $this->Execute( $query );
if( !$result )
return( "" );
-
+
$ids = Array();
while( $row = $result->FetchRow()) {
$ids[] = $row['article_id'];
More information about the pLog-svn
mailing list