codeigniter 3 database seeder code example

Example 1: codeigniter 4 db seed

> php spark db:seed TestSeeder

Example 2: codeigniter 4 database seed multiple

<?php

namespace App\Database\Seeds;

use \CodeIgniter\I18n\Time;

class PeopleSeeder extends \CodeIgniter\Database\Seeder
{
  public function run()
  {
    $data = [
      [
        'name'        => 'Andy',
        'address'     => '8733 Apple Street, 10',
        'created_at'  => Time::now(),
        'updated_at'  => Time::now()
      ],
      [
        'name'        => 'Buddy',
        'address'     => '643 Banana Street, 135',
        'created_at'  => Time::now(),
        'updated_at'  => Time::now()
      ],
      [
        'name'        => 'Anie',
        'address'     => '112 Lemon Street, 121',
        'created_at'  => Time::now(),
        'updated_at'  => Time::now()
      ]
    ];

    // Using Query Builder
    $this->db->table('peoples')->insertBatch($data);
  }
}