PHP Version
8.2
CodeIgniter4 Version
4.6.3
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
10.4.32-MariaDB
What happened?
Calling builder's replace() method sets updated_at to current time but sets created_at to '0000-00-00 00:00:00'
Closest issue found was #5229 (closed)
Table structure
CREATETABLE `translation` (
`translation_id`int(10) UNSIGNED NOT NULL,
`language_id`int(10) UNSIGNED NOT NULL,
`table`varchar(255) NOT NULL,
`row`varchar(255) NOT NULL,
`name`varchar(255) NOT NULL,
`value`textNOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
ALTERTABLE`translation`
ADD PRIMARY KEY (`translation_id`),
ADD KEY `list` (`language_id`,`table`,`row`,`name`) USING BTREE,
ADD KEY `edit` (`table`,`row`,`name`) USING BTREE,
ADD KEY `delete` (`table`,`row`) USING BTREE,
ADD KEY `sort` (`value`(16)) USING BTREE;
ALTERTABLE`translation`
MODIFY `translation_id`int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;
COMMIT;
Steps to Reproduce
Relevant portion of our model
<?phpnamespaceApp\Models;
class UserGroupModel extends BaseModel {
protectedfunctionafterSave(array$data): void {
if ($data['result']) {
foreach (request()->getPost('names') as$language_id => $name) {
model('TranslationModel')->replace([
'language_id' => $language_id,
'table' => $this->table,
'row' => $data['id'],
'name' => 'name',
'value' => $name,
]);
}
}
}
}Row export from phpMyAdmin
INSERT INTO`translation` (`translation_id`, `language_id`, `table`, `row`, `name`, `value`, `created_at`, `updated_at`, `deleted_at`) VALUES
(18, 2, 'user_group', '25', 'name', 'El Test', '0000-00-00 00:00:00', '2025-08-26 19:34:21', NULL);
Expected Output
Expected created_at to match updated_at
INSERT INTO`translation` (`translation_id`, `language_id`, `table`, `row`, `name`, `value`, `created_at`, `updated_at`, `deleted_at`) VALUES
(18, 2, 'user_group', '25', 'name', 'El Test', '2025-08-26 19:34:21', '2025-08-26 19:34:21', NULL);
Anything else?
No response
PHP Version
8.2
CodeIgniter4 Version
4.6.3
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
10.4.32-MariaDB
What happened?
Calling builder's
replace()method setsupdated_atto current time but setscreated_atto '0000-00-00 00:00:00'Closest issue found was #5229 (closed)
Table structure
Steps to Reproduce
Relevant portion of our model
Row export from phpMyAdmin
Expected Output
Expected
created_atto matchupdated_atAnything else?
No response