How to seed data in the encoder

How to put data into CodeIgniter after migration? I want to seed some defining users after migrating a user table after the migration is complete.

defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Users extends CI_Migration {

    public function up()
    {
        $this->load->database();
        $dbprefix = $this->db->dbprefix;
        $this->dbforge->add_field(array(
                'id' => array(
                        'type' => 'INT',
                        'constraint' =>11,
                        'unsigned' => TRUE,
                        'auto_increment' => TRUE
                ),
                'first_name' => array(
                        'type' => 'VARCHAR',
                        'constraint' => 50
                ),
                'last_name' => array(
                        'type' => 'VARCHAR',
                        'constraint' => 50,
                )
             ));
       $this->dbforge->add_key('id', TRUE);
        $this->dbforge->create_table('users');
      }

    public function down()
    {
            $this->dbforge->drop_table('users');
    }
 }

      

+3


source to share





All Articles