INSERT IGNORE using Codeigniter

后端 未结 13 942
眼角桃花
眼角桃花 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:33

    This is basically a modification of Rocket Hazmat's suggestion, which is great, but doesn't take into account the fact that str_replace operates on the entire string and might inadvertently affect the data.

    $insert_query = $this->db->insert_string('my_table', $data);
    $insert_query = preg_replace('/INSERT INTO/','INSERT IGNORE INTO',$insert_query,1);
    $this->db->query($insert_query);
    

提交回复
热议问题