-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_categories.php
More file actions
46 lines (34 loc) · 1.19 KB
/
update_categories.php
File metadata and controls
46 lines (34 loc) · 1.19 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
<?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 `newscat`
CHANGE `ID` `id` SMALLINT( 6 ) NOT NULL AUTO_INCREMENT ,
CHANGE `Cat` `name` VARCHAR( 64 ) CHARACTER SET utf8 NOT NULL,
CHANGE `ParentID` `parent_category_id` SMALLINT( 6 ) NOT NULL ,
CHANGE `Typ` `type` SMALLINT( 6 ) NOT NULL ,
CHANGE `Beschreibung` `description` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci;';
$result = $mysqli->multi_query($sql);
if (!$result) {
echo '<pre>'; print_r($mysqli); echo '</pre>';
echo 'could not change fields in table newscat' . $line_end;
} else {
echo 'changed fields in table newscat' . $line_end;
}
$sql = 'RENAME TABLE `'.DB_NAME.'`.`newscat` TO `'.DB_NAME.'`.`categories` ;';
$result = $mysqli->multi_query($sql);
if (!$result) {
echo 'could not rename table';
} else {
echo 'renamed table newscat to categories' . $line_end;
}
?>