-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_comments.php
More file actions
48 lines (36 loc) · 1.3 KB
/
update_comments.php
File metadata and controls
48 lines (36 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
include_once ('classes/Database.php');
include_once ('user/local.php');
# database options
$db = Database::getDB();
$mysqli = $db->getCon();
# line endings
if (php_sapi_name() == 'cli') {
$line_end = "\n";
} else {
$line_end = '<br>' . "\n";
}
# rename comment fields
$sql = 'ALTER TABLE `kommentare`
CHANGE `ID` `id` SMALLINT( 6 ) NOT NULL AUTO_INCREMENT ,
CHANGE `UID` `user_id` SMALLINT( 6 ) NOT NULL ,
CHANGE `NewsID` `article_id` SMALLINT( 6 ) NOT NULL ,
CHANGE `ParentID` `parent_comment_id` SMALLINT( 6 ) NOT NULL ,
CHANGE `Inhalt` `content` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ,
CHANGE `Datum` `date` DATETIME NOT NULL,
CHANGE `Frei` `enabled` TINYINT( 1 ) NOT NULL;';
$result = $mysqli->multi_query($sql);
if (!$result) {
echo '<pre>'; print_r($mysqli); echo '</pre>';
echo 'could not change fields in table kommentare' . $line_end;
} else {
echo 'changed fields in table kommentare' . $line_end;
}
$sql = 'RENAME TABLE `'.DB_NAME.'`.`kommentare` TO `'.DB_NAME.'`.`comments` ;';
$result = $mysqli->multi_query($sql);
if (!$result) {
echo 'could not rename table';
} else {
echo 'renamed table kommentare to comments' . $line_end;
}
?>