Search code examples
codeigniter-2

Using migrations in codeigniter


I have this query, I made a migrations file to make table structure for users table in my database but I do not understand how can I insert one row using this migration file because there has to be at least one user in the table. Kindly help


Solution

  • Good Day, You would first run your migrations which will create the table(s). Then run insert queries to insert your basic information that you need. I think the easiest way to do this is to use the database class and active record.

    $insert_data = array(
        'vchFirstname' => 'Donald',
        'vchLastName'  => 'Duck'
    );
    $this->db->insert('cartoons',$insert_data);
    

    You can read more about this here: http://ellislab.com/codeigniter/user-guide/database/active_record.html#insert