| | 150 | $contents{$node_id."-".$version} = \%content; |
| | 151 | } |
| | 152 | |
| | 153 | # Grab all the metadata |
| | 154 | $sth = $dbh->prepare("SELECT node_id,version,metadata_type,metadata_value FROM metadata"); |
| | 155 | $sth->execute; |
| | 156 | my $i = 0; |
| | 157 | while( my($node_id,$version,$metadata_type,$metadata_value) = $sth->fetchrow_array) { |
| | 158 | my %metadata; |
| | 159 | $metadata{'node_id'} = $node_id; |
| | 160 | $metadata{'version'} = $version; |
| | 161 | $metadata{'metadata_type'} = $metadata_type; |
| | 162 | $metadata{'metadata_value'} = $metadata_value; |
| | 163 | $metadatas{$node_id."-".($i++)} = \%metadata; |
| | 164 | } |
| | 165 | |
| | 166 | # Grab all the internal links |
| | 167 | $sth = $dbh->prepare("SELECT link_from,link_to FROM internal_links"); |
| | 168 | $sth->execute; |
| | 169 | while( my($link_from,$link_to) = $sth->fetchrow_array) { |
| | 170 | my %il; |
| | 171 | $il{'link_from'} = $link_from; |
| | 172 | $il{'link_to'} = $link_to; |
| | 173 | push @internal_links, \%il; |
| | 174 | } |
| | 175 | |
| | 176 | print "done\n"; |
| | 177 | |
| | 178 | # Return it all |
| | 179 | return (\%nodes,\%contents,\%metadatas,\@internal_links); |
| | 180 | } |
| | 181 | |
| | 182 | # Fetch from schema version 9, and upgrade to version 10 |
| | 183 | sub fetch_upgrade_9_to_10 { |
| | 184 | my $dbh = shift; |
| | 185 | my %nodes; |
| | 186 | my %metadatas; |
| | 187 | my %contents; |
| | 188 | my @internal_links; |
| | 189 | |
| | 190 | print "Grabbing and upgrading old data... "; |
| | 191 | |
| | 192 | # Grab all the nodes |
| | 193 | my $sth = $dbh->prepare("SELECT id,name,version,text,modified,moderate FROM node"); |
| | 194 | $sth->execute; |
| | 195 | while( my($id,$name,$version,$text,$modified,$moderate) = $sth->fetchrow_array) { |
| | 196 | my %node; |
| | 197 | $node{'name'} = $name; |
| | 198 | $node{'version'} = $version; |
| | 199 | $node{'text'} = $text; |
| | 200 | $node{'modified'} = $modified; |
| | 201 | $node{'id'} = $id; |
| | 202 | $node{'moderate'} = $moderate; |
| | 203 | $nodes{$name} = \%node; |
| | 204 | } |
| | 205 | |
| | 206 | # Grab all the content |
| | 207 | $sth = $dbh->prepare("SELECT node_id,version,text,modified,comment,moderated FROM content"); |
| | 208 | $sth->execute; |
| | 209 | while ( my($node_id,$version,$text,$modified,$comment,$moderated) = $sth->fetchrow_array) { |
| | 210 | my %content; |
| | 211 | $content{'node_id'} = $node_id; |
| | 212 | $content{'version'} = $version; |
| | 213 | $content{'text'} = $text; |
| | 214 | $content{'modified'} = $modified; |
| | 215 | $content{'comment'} = $comment; |
| | 216 | $content{'moderated'} = $moderated; |