Welcome Guest, Not a member yet? Register   Sign In
Seeder on migration
#2

(This post was last modified: 08-12-2020, 11:43 AM by InsiteFX.)

You would need to do a insertBatch.

PHP Code:
$this->db->table('blog')->insertBatch([
    [
        'parent_id'  => '0',
        'title'      => 'Test1',
        'body'       => 'This is the body',
        'created_at' => date('Y-m-d H:i:s'),
        'updated_at' => date('Y-m-d H:i:s'),
    ],
    [
        'parent_id'  => '1',
        'title'      => 'Test2',
        'body'       => 'This is another body',
        'created_at' => date('Y-m-d H:i:s'),
        'updated_at' => date('Y-m-d H:i:s'),
    ],
]); 

You may also be able to use a foreach loop if you need to input lots of data from a file or something.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Seeder on migration - by pippuccio76 - 08-12-2020, 10:55 AM
RE: Seeder on migration - by InsiteFX - 08-12-2020, 11:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB