在迁移时间上添加了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;           
    }
dongyan2445
dongyan2445 我只想要在下面条件下的单个字段详细信息来匹配字段详细信息。如果(!$admin_db->field_exists($field,'cms_page')){},我可以使用“ADD”或“修改”关键字识别更改
大约 5 年之前 回复
duanfenhui5511
duanfenhui5511 [ellislab.com/codeigniter/user-guide/database/fields.html]粗体如何在下面的例子中放置一个conditin示例$fields=$this->db->field_data('table_name');foreach($fieldsas$field){echo$field->name;echo$field->type;echo$field->max_length;echo$field->primary_key;}
大约 5 年之前 回复
douding_1073
douding_1073 是否有任何代码点火器方法来匹配所有属性的字段?
大约 5 年之前 回复
duanmeng2842
duanmeng2842 stackoverflow.com/questions/5824722/...
大约 5 年之前 回复
drz73366
drz73366 我无法获得类型,密钥等字段详细信息
大约 5 年之前 回复
dongmi19720408
dongmi19720408 可能重复如何将新列添加到MYSQL表
大约 5 年之前 回复
dsmlf1207915
dsmlf1207915 你有什么尝试?你无法解决的特殊问题是什么?如果你想知道如何在PHP中执行DDL查询,我确信有很多Q&A解决方案。
大约 5 年之前 回复
dongzhi2887
dongzhi2887 这不是一个问题,而是一个公告。
大约 5 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐