forked from glpunzi/nuBuilderPro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuupdatesch_lib.php
63 lines (47 loc) · 1.77 KB
/
nuupdatesch_lib.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class nuupdatesch {
var $sqlErrors = array();
var $tables_updated = array();
var $DBHost = '';
var $DBName = '';
var $DBUserID = '';
var $DBPassWord = '';
var $zzsys_only = true;
function update() {
$db = $this->DBName;
$sql = "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '$db' ";
$rs = $this->runQuery($sql);
while($obj = mysql_fetch_object($rs)) {
$thisTablePrefix = substr($obj->TABLE_NAME, 0, 7);
if ( $this->zzsys_only ) {
if ( $thisTablePrefix == 'zzzsys_' ) {
$this->execute($obj->TABLE_NAME);
}
} else {
$this->execute($obj->TABLE_NAME);
}
}
}
function execute($table) {
$sql = "ALTER TABLE $table ENGINE = MYISAM";
$this->runQuery($sql);
$sql = "ALTER TABLE $table DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ";
$this->runQuery($sql);
$sql = "ALTER TABLE $table CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci ";
$this->runQuery($sql);
array_push($this->tables_updated, $table);
}
function runQuery($pSQL) {
$con = mysql_connect($this->DBHost, $this->DBUserID, $this->DBPassWord) or die ("Could not connect to database\n");
mysql_select_db($this->DBName,$con) or die ("Could not select database\n");
$rs = mysql_query($pSQL);
if ( "" != mysql_error($con) ) {
$errors[0] = mysql_errno($con);
$errors[1] = mysql_error($con);
$errors[2] = $pSQL;
array_push($this->sqlErrors, $errors);
}
return $rs;
}
}
?>