ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
db\_table\_fix\_sql() - 创建修复两张差异表 ### 说明 ~~~ db_table_fix_sql($schema1, $schema2, $strict = false) ~~~ ### 参数 * **$schema1**表结构 需要修复的表 * **$schema2**表结构 基准表 * **$strict**使用严格模式, 严格模式将会把表2完全变成表1的结构, 否则将只处理表2种大于表1的内容(多出的字段和索引) ### 示例 ~~~ $id = array('type' => 'id', 'default' => 12, 'increment' => 'AUTO_INCREMENT');$sex = array('type' => 'sex', 'default' => 1);$age = array('type' => 'age', 'default' => 0);$index = array('fields' => array('id'), 'type' => 'primary');$table1 = array('tablename' => 'zefeng', 'fields' => array($id, $sex, $age), 'indexes' => array($index), 'engine' => 'InnoDB', 'charset' => 'utf8');$id = array('type' => 'id', 'default' => 12, 'increment' => 'AUTO_INCREMENT');$name = array('type' => 'name', 'default' => 11);$age = array('type' => 'ages', 'default' => 0);$index = array('fields' => array('name'), 'type' => 'index');$table2 = array('tablename' => 'zefeng', 'fields' => array($id, $name, $age), 'indexes' => array($index), 'engine' => 'InnoDB', 'charset' => 'utf8');var_dump(db_table_fix_sql($table1, $table2));array (size=3) 0 => string 'ALTER TABLE `zefeng` CHANGE `` `` name unsigned NOT NULL DEFAULT '11'' (length=69) 1 => string 'ALTER TABLE `zefeng` CHANGE `` `` ages unsigned NOT NULL DEFAULT '0'' (length=68) 2 => string 'ALTER TABLE `zefeng` DROP PRIMARY KEY , ADD INDEX `` (`name`)' (length=63) ~~~