Reputation: 555
There are three table as t1, t2 and t3. I'm trying to insert my row to multiple table using CodeIgniter as given above.
Code:
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name' ,
'email' => 'E-mail'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name' ,
'email' => 'E-mail'
),
array(
'title' => 'Another title 2' ,
'name' => 'Another Name 2' ,
'email' => 'E-mail 2'
)
);
$i=1;
for($k=0;$k<3;$k++){
$this->db->insert_batch('t'.$i++, $data);
}
Upvotes: 0
Views: 70
Reputation:
I hope , this stuff will work for you, just try this.
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name' ,
'email' => 'E-mail'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name' ,
'email' => 'E-mail'
),
array(
'title' => 'Another title 2' ,
'name' => 'Another Name 2' ,
'email' => 'E-mail 2'
)
);
$i=1;
for($k=0;$k<3;$k++)
{
$this->db->insert_batch('t'.$i++, $data);
}
Upvotes: 3