INSERT IGNORE using Codeigniter

后端 未结 13 945
眼角桃花
眼角桃花 2020-12-08 19:52

I am trying to insert a few rows into the MySQL table using Codeigniter and Active Records.

PHP Code

$data = array(\'......\');  //          


        
13条回答
  •  轮回少年
    2020-12-08 20:28

    I too had same issue what helped me is :

    Open : Codeigniter/system/database/DB_query_builder.php :

    find

    protected function _insert_batch($table, $keys, $values)
        {
            return 'INSERT INTO '.$table.' ('.implode(', ', $keys).') VALUES '.implode(', ', $values);
        }
    

    and replace with :

    protected function _insert_batch($table, $keys, $values)
    {
        return 'INSERT IGNORE INTO '.$table.' ('.implode(', ', $keys).') VALUES '.implode(', ', $values);
    }
    

提交回复
热议问题