codeigniter 4 db seed
> php spark db:seed TestSeeder
codeigniter 4 db seed
> php spark db:seed TestSeeder
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);
}
}
codeigniter 4 db seed
<?php namespace App\Database\Seeds;
class SimpleSeeder extends \CodeIgniter\Database\Seeder
{
public function run()
{
$data = [
'username' => 'darth',
'email' => '[email protected]'
];
// Simple Queries
$this->db->query("INSERT INTO users (username, email) VALUES(:username:, :email:)",
$data
);
// Using Query Builder
$this->db->table('users')->insert($data);
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us