Mercurial > defr > drupal > core
comparison modules/search/search.module @ 11:589fb7c02327 6.5
Drupal 6.5
author | Franck Deroche <webmaster@defr.org> |
---|---|
date | Tue, 23 Dec 2008 14:32:19 +0100 |
parents | acef7ccb09b5 |
children |
comparison
equal
deleted
inserted
replaced
10:6f15c9d74937 | 11:589fb7c02327 |
---|---|
1 <?php | 1 <?php |
2 // $Id: search.module,v 1.250.2.3 2008/08/13 06:59:49 dries Exp $ | 2 // $Id: search.module,v 1.250.2.4 2008/09/17 06:42:20 goba Exp $ |
3 | 3 |
4 /** | 4 /** |
5 * @file | 5 * @file |
6 * Enables site-wide keyword searching. | 6 * Enables site-wide keyword searching. |
7 */ | 7 */ |
570 // Insert cleaned up data into dataset | 570 // Insert cleaned up data into dataset |
571 db_query("INSERT INTO {search_dataset} (sid, type, data, reindex) VALUES (%d, '%s', '%s', %d)", $sid, $type, $accum, 0); | 571 db_query("INSERT INTO {search_dataset} (sid, type, data, reindex) VALUES (%d, '%s', '%s', %d)", $sid, $type, $accum, 0); |
572 | 572 |
573 // Insert results into search index | 573 // Insert results into search index |
574 foreach ($results[0] as $word => $score) { | 574 foreach ($results[0] as $word => $score) { |
575 // The database will collate similar words (accented and non-accented forms, etc.), | 575 // Try inserting first because this will succeed most times, but because |
576 // and the score is additive, so first add and then insert. | 576 // the database collates similar words (accented and non-accented), the |
577 db_query("UPDATE {search_index} SET score = score + %d WHERE word = '%s' AND sid = '%d' AND type = '%s'", $score, $word, $sid, $type); | 577 // insert can fail, in which case we need to add the word scores together. |
578 @db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score); | |
578 if (!db_affected_rows()) { | 579 if (!db_affected_rows()) { |
579 db_query("INSERT INTO {search_index} (word, sid, type, score) VALUES ('%s', %d, '%s', %f)", $word, $sid, $type, $score); | 580 db_query("UPDATE {search_index} SET score = score + %f WHERE word = '%s' AND sid = %d AND type = '%s'", $score, $word, $sid, $type); |
580 } | 581 } |
581 search_dirty($word); | 582 search_dirty($word); |
582 } | 583 } |
583 unset($results[0]); | 584 unset($results[0]); |
584 | 585 |