Answers for "codeigniter 4 database seed multiple"

PHP
0

codeigniter 4 db seed

> php spark db:seed TestSeeder
Posted by: Guest on December-04-2020
0

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);
  }
}
Posted by: Guest on December-04-2020
0

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);
        }
}
Posted by: Guest on December-04-2020

Browse Popular Code Answers by Language