drzil26260 2015-09-21 10:35
浏览 20

在迁移时间上添加了codeigniter动态字段

i have two database called "migrate_new" and "migrate_old" and both have one table called "cms_pages".

i want to compare "migrate_old" db "cms_pages" with the "migrate_new" "cms_pages" table structure if "migrate_new" database "cms_pages" does not have "field" then alter table automatically.

below is my code to compare "migrate_old" "cms_pages" fields not in "migrate_new" "cms_pages" now i want to add this fields on table. i want to continue the process in place of exit.

**> any one can have idea to add fields automatically so no need to stop migration task?

i am not able to get field details like type , key , etc. how i know alter table with use modify or add fields. i short i want to set structure with out loss of any data automatically. thanks in advance..
**

    $this->load->database();
    $admin_db = $this->load->database('ADMINDB', TRUE);

    $query = $this->db->get('cms_page');
    $result = $query->result();

    $fields_old = $this->db->list_fields('cms_page');
//  $fields_new = $admin_db->list_fields('cms_page');
    $flag = false;
    foreach ($fields_old as $field){

        if (!$admin_db->field_exists($field, 'cms_page'))
        {
            echo $field.'=> is not exists in new table please contact to developer for that <br>';
            $flag = true;
        }
    }

    if($flag){
        exit;           
    }
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?