09-29-2020, 12:17 AM
I'm building a seeder to populate the database, but I'm not able to set NOW() in DATETIME fields. How can I do it?
I tried this:
And also with literal 'NOW()' here:
None of them works.
I tried this:
PHP Code:
public function run() {
helper('date');
$now = now();
$data = [
[
'user_id' => 1,
'group_id' => 1,
'created_at' => $now,
'updated_at' => $now
],
[
'user_id' => 1,
'group_id' => 2,
'created_at' => $now,
'updated_at' => $now
],
[
'user_id' => 2,
'group_id' => 2,
'created_at' => $now,
'updated_at' => $now
]
];
$this->db->table('back_user_groups_rel')->insertBatch($data);
}
And also with literal 'NOW()' here:
PHP Code:
$now = 'NOW()';
None of them works.