forked from MineWeb/MineWebCMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodify.php
More file actions
executable file
·42 lines (41 loc) · 1.18 KB
/
modify.php
File metadata and controls
executable file
·42 lines (41 loc) · 1.18 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
<?php
$db = ConnectionManager::getDataSource('default');
// for all update
function add_column($table, $name, $sql) {
//global $db;
$db = ConnectionManager::getDataSource('default');
$verif = $db->query('SHOW COLUMNS FROM '.$table.';');
$execute = true;
foreach ($verif as $k => $v) {
if($v['COLUMNS']['Field'] == $name) {
$execute = false;
break;
}
}
if($execute) {
@$query = $db->query('ALTER TABLE `'.$table.'` ADD `'.$name.'` '.$sql.';');
}
}
function remove_column($table, $name) {
//global $db;
$db = ConnectionManager::getDataSource('default');
$verif = $db->query('SHOW COLUMNS FROM '.$table.';');
$execute = false;
foreach ($verif as $k => $v) {
if($v['COLUMNS']['Field'] == $name) {
$execute = true;
break;
}
}
if($execute) {
@$query = $db->query('ALTER TABLE `'.$table.'` DROP COLUMN `'.$name.'`;');
}
}
// 1.8.0
add_column('users', 'uuid', 'varchar(255) DEFAULT NULL AFTER `pseudo`');
add_column('configurations', 'uuid', 'int(1) DEFAULT \'0\' AFTER `end_layout_code`');
// end 1.8.0
@clearFolder(ROOT.'/app/tmp/cache/models/');
@clearFolder(ROOT.'/app/tmp/cache/persistent/');
@unlink(ROOT.DS.'lang'.DS.'fr.json');
?>