CodeIgniter Laravel PHP Example Javascript jQuery MORE
Need a Website Or Web Application.Contact : +91 9437911966 (Whatsapp) Note: Paid Service

Codeigniter Batch Insert Example


$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);
Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'),  ('Another title', 'Another name', 'Another date')
 Using For each
$final_data=array();
foreach($service_ids as $service_id){
array_push($final_data, array(
'FileID'=>$insert_id,
'ServiceID'=>(int)$service_id

));
$counter ++;
}

$this->db->insert_batch('filedocument', $final_data);