Welcome Guest, Not a member yet? Register   Sign In
Database Seeder
#1

Is there a way to put multiple datasets into the $data variable described here?
https://codeigniter.com/user_guide/dbmgmt/seeds.html

I try to go with a multidimensional array but it tells me that there is a mysql error :$
Reply
#2

The $data can only be one level because it is defining the columns in the database table.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

you can do as follows to be able to insert multiple records

$data_category = [
array('category' => 'Test 01', 'ordination' => '1'),
array('category' => 'Test 02', 'ordination' => '2'),
array('category' => 'Test 03', 'ordination' => '3'),
array('category' => 'Test 04', 'ordination' => '4')
];

// Using Query Builder
$this->db->table('categories')->emptyTable();
$this->db->table('categories')->insertBatch($data_category);

Hope this helps
Reply




Theme © iAndrew 2016 - Forum software by © MyBB