一尘不染

如何创建Codeigniter批处理插入数组

php

我如何创建一个CI批处理插入数组,就像

$data = array(
   array(
      'title' => 'My title' ,
      'name' => 'My Name' ,
      'date' => 'My date'
   ),
   array(
      'title' => 'Another title' ,
      'name' => 'Another Name' ,
      'date' => 'Another date'
   )
);

从我的正常数组是

Array
(
    [0] => Array
        (
            [track_id] => 
            [camp_id] => 1
            [field_name] => email_title
            [field_value] => sample
        )

    [1] => Array
        (
            [track_id] => 
            [camp_id] => 1
            [field_name] => email_date
            [field_value] => 2013-07-02
        )

    [2] => Array
        (
            [track_id] => 
            [camp_id] => 1
            [field_name] => email_template
            [field_value] => 2
        )
)

阅读 192

收藏
2020-05-29

共1个答案

一尘不染

尝试这个:

$data = array(
   array(
      'title' => 'My title' ,
      'name' => 'My Name' ,
      'date' => 'My date'
   ),
   array(
      'title' => 'Another title' ,
      'name' => 'Another Name' ,
      'date' => 'Another date'
   )
);

$this->db->insert_batch('mytable', $data);

欲了解更多信息,请点击这里

2020-05-29