cargar seeder en codeigniter 4 code example
Example 1: codeigniter 4 db seed
<?php namespace App\Database\Seeds;
class TestSeeder extends \CodeIgniter\Database\Seeder
{
public function run()
{
$this->call('UserSeeder');
$this->call('CountrySeeder');
$this->call('JobSeeder');
}
}
Example 2: codeigniter 4 db seed
<?php namespace App\Database\Seeds;
class SimpleSeeder extends \CodeIgniter\Database\Seeder
{
public function run()
{
$data = [
'username' => 'darth',
'email' => '[email protected]'
];
$this->db->query("INSERT INTO users (username, email) VALUES(:username:, :email:)",
$data
);
$this->db->table('users')->insert($data);
}
}