我如何创建一个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 ) )
尝试这个:
$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);
欲了解更多信息,请点击这里