目前我使用这样的数组来控制 Mysql 数据库的版本:
$pages_table = array (
"GUID" => array (
"type" => "CHAR(13)",
"length" => 13,
)
"Number" => array (
"type" => "TINYINT(4)",
"length" => 4,
)
"Pagename" => array (
"type" => "VARCHAR(30)",
"length" => 30,
)
它有效,但我想让它更干净,比如:
$pages_table = array (
"GUID" => "CHAR(13)",
"Number" => "TINYINT(4)",
"Pagename" => "VARCHAR(30)",
);
然后,如果我遍历数组,我想将 $new_length (INT) 设置为 $new_type 字符串括号之间的数字:
while ($column = key($pages_table)) {
$new_type = current($pages_table);
$new_length = //Get this value from $new_type;
if ($existing_table[$column]['length'] < $new_length) {
$modify[$column] = $new_type;
}
next($pages_table);
}