Changeset 290 for wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/Database.pm
- Timestamp:
- 05/18/06 14:32:00 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/Database.pm
r288 r290 25 25 my %metadatas; 26 26 my %contents; 27 my @internal_links; 27 28 my %ids; 28 29 … … 85 86 } 86 87 88 # Grab all the internal links 89 $sth = $dbh->prepare("SELECT link_from,link_to FROM internal_links"); 90 $sth->execute; 91 while( my($link_from,$link_to) = $sth->fetchrow_array) { 92 my %il; 93 $il{'link_from'} = $link_from; 94 $il{'link_to'} = $link_to; 95 push @internal_links, \%il; 96 } 97 87 98 print "done\n"; 88 99 89 100 # Return it all 90 return (\%nodes,\%contents,\%metadatas,\ %ids);101 return (\%nodes,\%contents,\%metadatas,\@internal_links,\%ids); 91 102 } 92 103 # Fetch from schema version 8, and upgrade to version 9 … … 96 107 my %metadatas; 97 108 my %contents; 109 my @internal_links; 98 110 99 111 print "Grabbing and upgrading old data... "; … … 140 152 } 141 153 154 # Grab all the internal links 155 $sth = $dbh->prepare("SELECT link_from,link_to FROM internal_links"); 156 $sth->execute; 157 while( my($link_from,$link_to) = $sth->fetchrow_array) { 158 my %il; 159 $il{'link_from'} = $link_from; 160 $il{'link_to'} = $link_to; 161 push @internal_links, \%il; 162 } 163 142 164 print "done\n"; 143 165 144 166 # Return it all 145 return (\%nodes,\%contents,\%metadatas );167 return (\%nodes,\%contents,\%metadatas,\@internal_links); 146 168 } 147 169 … … 183 205 # Put the latest data into the latest database structure 184 206 sub bulk_data_insert { 185 my ($dbh, $nodesref, $contentsref, $metadataref ) = @_;207 my ($dbh, $nodesref, $contentsref, $metadataref, $internallinksref) = @_; 186 208 187 209 print "Bulk inserting upgraded data... "; … … 212 234 } 213 235 214 # Add metadata215 $sth = $dbh->prepare("INSERT INTO metadata (node_id,version,metadata_type,metadata_value) VALUES (?,?,?,?)");216 foreach my $key (keys %$metadataref) {217 my %metadata = %{$metadataref->{$key}};218 $sth->execute($metadata{'node_id'},236 # Add metadata 237 $sth = $dbh->prepare("INSERT INTO metadata (node_id,version,metadata_type,metadata_value) VALUES (?,?,?,?)"); 238 foreach my $key (keys %$metadataref) { 239 my %metadata = %{$metadataref->{$key}}; 240 $sth->execute($metadata{'node_id'}, 219 241 $metadata{'version'}, 220 242 $metadata{'metadata_type'}, 221 243 $metadata{'metadata_value'}); 222 } 223 224 print "done\n"; 225 } 244 } 245 246 # Add internal links 247 $sth = $dbh->prepare("INSERT INTO internal_links (link_from,link_to) VALUES (?,?)"); 248 foreach my $ilr (@$internallinksref) { 249 my %il = %{$ilr}; 250 $sth->execute($il{'link_from'}, 251 $il{'link_to'}); 252 } 253 254 print "done\n"; 255 }
