codeigniter 4 database seed multiple

Solutions on MaxInterview for codeigniter 4 database seed multiple by the best coders in the world

showing results for - "codeigniter 4 database seed multiple"
Sandy
10 Jun 2018
1> php spark db:seed TestSeeder
2
Alaina
02 Jan 2017
1
2
3<?php
4
5namespace App\Database\Seeds;
6
7use \CodeIgniter\I18n\Time;
8
9class PeopleSeeder extends \CodeIgniter\Database\Seeder
10{
11  public function run()
12  {
13    $data = [
14      [
15        'name'        => 'Andy',
16        'address'     => '8733 Apple Street, 10',
17        'created_at'  => Time::now(),
18        'updated_at'  => Time::now()
19      ],
20      [
21        'name'        => 'Buddy',
22        'address'     => '643 Banana Street, 135',
23        'created_at'  => Time::now(),
24        'updated_at'  => Time::now()
25      ],
26      [
27        'name'        => 'Anie',
28        'address'     => '112 Lemon Street, 121',
29        'created_at'  => Time::now(),
30        'updated_at'  => Time::now()
31      ]
32    ];
33
34    // Using Query Builder
35    $this->db->table('peoples')->insertBatch($data);
36  }
37}
38
39
40
Shadrach
23 Oct 2016
1<?php namespace App\Database\Seeds;
2
3class SimpleSeeder extends \CodeIgniter\Database\Seeder
4{
5        public function run()
6        {
7                $data = [
8                        'username' => 'darth',
9                        'email'    => 'darth@theempire.com'
10                ];
11
12                // Simple Queries
13                $this->db->query("INSERT INTO users (username, email) VALUES(:username:, :email:)",
14                        $data
15                );
16
17                // Using Query Builder
18                $this->db->table('users')->insert($data);
19        }
20}
21