CodeIgniter Forums

Full Version: How to Insert auto multiple row in database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Please would you help me  How to Insert auto multiple row in database?
have tried but fail .
 
Perhaps if you try explaining (in much more detail) what you're trying to do, we can help.
PHP Code:
$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); 

Above from the docs.
https://www.codeigniter.com/user_guide/d...rting-data
(You have to scroll down a bit to the end of that section).

1. Get your data together however you want (from a form input, from a curl, from an admin screen etc)
2. Create your multi dimensional array.
3. Use update_batch to insert multiple rows.

Easy peasy. Lightweight. Fast. Powerful. Flexible. As most things CI are :-)

Hope that helps.

Paul.

PS You would get a more specific answer if you posted what you had "tried and failed". (What did you try? What did you expect? What did you get?)