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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 优质github账号直接兑换rmb,感兴趣伙伴可以私信
    • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
    • ¥15 安装svn网络有问题怎么办
    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)