Lines 20-25
return {
Link Here
|
20 |
`title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content', |
20 |
`title` varchar(250) NOT NULL DEFAULT '' COMMENT 'title of the additional content', |
21 |
`content` mediumtext NOT NULL COMMENT 'the body of your additional content', |
21 |
`content` mediumtext NOT NULL COMMENT 'the body of your additional content', |
22 |
`lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang', |
22 |
`lang` varchar(50) NOT NULL DEFAULT '' COMMENT 'lang', |
|
|
23 |
`updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', |
23 |
PRIMARY KEY (`id`), |
24 |
PRIMARY KEY (`id`), |
24 |
UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`), |
25 |
UNIQUE KEY `additional_contents_localizations_uniq` (`additional_content_id`,`lang`), |
25 |
CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
26 |
CONSTRAINT `additional_contents_localizations_ibfk1` FOREIGN KEY (`additional_content_id`) REFERENCES `additional_contents` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
Lines 29-47
return {
Link Here
|
29 |
|
30 |
|
30 |
my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} }); |
31 |
my $contents = $dbh->selectall_arrayref(q{SELECT MIN(id) AS id, category, code, branchcode FROM additional_contents GROUP BY category, code, branchcode}, { Slice => {} }); |
31 |
my $sth_insert = $dbh->prepare(q{ |
32 |
my $sth_insert = $dbh->prepare(q{ |
32 |
INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang) |
33 |
INSERT INTO additional_contents_localizations(additional_content_id, title, content, lang, updated_on) |
33 |
VALUES(?, ?, ?, ?) |
34 |
VALUES(?, ?, ?, ?, ?) |
34 |
}); |
35 |
}); |
35 |
for my $content ( @$contents ) { |
36 |
for my $content ( @$contents ) { |
36 |
my $q = q{ |
37 |
my $q = q{ |
37 |
SELECT title, content, lang, branchcode |
38 |
SELECT title, content, lang, branchcode, updated_on |
38 |
FROM additional_contents |
39 |
FROM additional_contents |
39 |
WHERE category=? AND code=? AND |
40 |
WHERE category=? AND code=? AND |
40 |
}; |
41 |
}; |
41 |
$q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL"; |
42 |
$q .= defined $content->{branchcode} ? " branchcode = ?" : " branchcode IS NULL"; |
42 |
my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ()); |
43 |
my $translated_contents = $dbh->selectall_arrayref($q, { Slice => {} }, $content->{category}, $content->{code}, defined $content->{branchcode} ? $content->{branchcode} : ()); |
43 |
for my $translated_content ( @$translated_contents ) { |
44 |
for my $translated_content ( @$translated_contents ) { |
44 |
$sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}); |
45 |
$sth_insert->execute($content->{id}, $translated_content->{title}, $translated_content->{content}, $translated_content->{lang}, $translated_content->{updated_on}); |
45 |
} |
46 |
} |
46 |
} |
47 |
} |
47 |
$dbh->do(q{ |
48 |
$dbh->do(q{ |