Changeset 431 for wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/DBIxFTSMySQL.pm
- Timestamp:
- 05/11/08 17:04:41 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/DBIxFTSMySQL.pm
r209 r431 37 37 38 38 sub setup { 39 my $dbh = _get_dbh( @_ );39 my $dbh = _get_dbh( @_ ); 40 40 41 # Drop FTS indexes if they already exist.42 my $fts = DBIx::FullTextSearch->open($dbh, "_content_and_title_fts");43 $fts->drop if $fts;44 $fts = DBIx::FullTextSearch->open($dbh, "_title_fts");45 $fts->drop if $fts;41 # Drop FTS indexes if they already exist. 42 my $fts = DBIx::FullTextSearch->open($dbh, "_content_and_title_fts"); 43 $fts->drop if $fts; 44 $fts = DBIx::FullTextSearch->open($dbh, "_title_fts"); 45 $fts->drop if $fts; 46 46 47 # Set up FullText indexes and index anything already extant.48 my $fts_all = DBIx::FullTextSearch->create($dbh, "_content_and_title_fts",49 frontend => "table",50 backend => "phrase",51 table_name => "node",52 column_name => ["name","text"],53 column_id_name => "name",54 stemmer => "en-uk");47 # Set up FullText indexes and index anything already extant. 48 my $fts_all = DBIx::FullTextSearch->create($dbh, "_content_and_title_fts", 49 frontend => "table", 50 backend => "phrase", 51 table_name => "node", 52 column_name => ["name","text"], 53 column_id_name => "name", 54 stemmer => "en-uk"); 55 55 56 my $fts_title = DBIx::FullTextSearch->create($dbh, "_title_fts",57 frontend => "table",58 backend => "phrase",59 table_name => "node",60 column_name => "name",61 column_id_name => "name",62 stemmer => "en-uk");56 my $fts_title = DBIx::FullTextSearch->create($dbh, "_title_fts", 57 frontend => "table", 58 backend => "phrase", 59 table_name => "node", 60 column_name => "name", 61 column_id_name => "name", 62 stemmer => "en-uk"); 63 63 64 my $sql = "SELECT name FROM node";65 my $sth = $dbh->prepare($sql);66 $sth->execute();67 while (my ($name, $version) = $sth->fetchrow_array) {68 $fts_title->index_document($name);69 $fts_all->index_document($name);70 }71 $sth->finish;64 my $sql = "SELECT name FROM node"; 65 my $sth = $dbh->prepare($sql); 66 $sth->execute(); 67 while (my ($name, $version) = $sth->fetchrow_array) { 68 $fts_title->index_document($name); 69 $fts_all->index_document($name); 70 } 71 $sth->finish; 72 72 } 73 73 … … 78 78 $dsn .= ";host=$dbhost" if $dbhost; 79 79 my $dbh = DBI->connect($dsn, $dbuser, $dbpass, 80 { PrintError => 1, RaiseError => 1,81 AutoCommit => 1 } )82 or croak DBI::errstr;80 { PrintError => 1, RaiseError => 1, 81 AutoCommit => 1 } ) 82 or croak DBI::errstr; 83 83 return $dbh; 84 84 }
