Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Batch DB::insert
  • Is there a way to do a batch insert? What I mean is this:
    $data = array(200) {
        [0] => array(2) {
            ['id'] => 1,
            ['name'] => 'name 1'
        },
        [1] => array(2) {
            ['id'] => 2,
            ['name'] => 'name 2'
        }
    /* ... */
    }
    
    DB::insert_batch('tbl', $data);
    

    This code should generate the following SQL:
    INSERT INTO `tbl` (`id`, `name`) VALUES (1, 'name 1'), (2, 'name 2'), ... (200, 'name 200');
    

    This would be so helpful... I don't know if this is MySQL specific but it would be helpful...
  • From what I can see in the code that is already supported by the Query Builder.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion