@@ -770,11 +770,11 @@ public function insert($data = null, bool $returnID = true)
770770 // Set created_at and updated_at with same time
771771 $ date = $ this ->setDate ();
772772
773- if ($ this ->useTimestamps && $ this ->createdField && ! array_key_exists ($ this ->createdField , $ data )) {
773+ if ($ this ->useTimestamps && $ this ->createdField !== '' && ! array_key_exists ($ this ->createdField , $ data )) {
774774 $ data [$ this ->createdField ] = $ date ;
775775 }
776776
777- if ($ this ->useTimestamps && $ this ->updatedField && ! array_key_exists ($ this ->updatedField , $ data )) {
777+ if ($ this ->useTimestamps && $ this ->updatedField !== '' && ! array_key_exists ($ this ->updatedField , $ data )) {
778778 $ data [$ this ->updatedField ] = $ date ;
779779 }
780780
@@ -857,11 +857,11 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
857857 // Set created_at and updated_at with same time
858858 $ date = $ this ->setDate ();
859859
860- if ($ this ->useTimestamps && $ this ->createdField && ! array_key_exists ($ this ->createdField , $ row )) {
860+ if ($ this ->useTimestamps && $ this ->createdField !== '' && ! array_key_exists ($ this ->createdField , $ row )) {
861861 $ row [$ this ->createdField ] = $ date ;
862862 }
863863
864- if ($ this ->useTimestamps && $ this ->updatedField && ! array_key_exists ($ this ->updatedField , $ row )) {
864+ if ($ this ->useTimestamps && $ this ->updatedField !== '' && ! array_key_exists ($ this ->updatedField , $ row )) {
865865 $ row [$ this ->updatedField ] = $ date ;
866866 }
867867 }
@@ -929,7 +929,7 @@ public function update($id = null, $data = null): bool
929929 throw DataException::forEmptyDataset ('update ' );
930930 }
931931
932- if ($ this ->useTimestamps && $ this ->updatedField && ! array_key_exists ($ this ->updatedField , $ data )) {
932+ if ($ this ->useTimestamps && $ this ->updatedField !== '' && ! array_key_exists ($ this ->updatedField , $ data )) {
933933 $ data [$ this ->updatedField ] = $ this ->setDate ();
934934 }
935935
@@ -1014,7 +1014,7 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
10141014 $ row [$ index ] = $ updateIndex ;
10151015 }
10161016
1017- if ($ this ->useTimestamps && $ this ->updatedField && ! array_key_exists ($ this ->updatedField , $ row )) {
1017+ if ($ this ->useTimestamps && $ this ->updatedField !== '' && ! array_key_exists ($ this ->updatedField , $ row )) {
10181018 $ row [$ this ->updatedField ] = $ this ->setDate ();
10191019 }
10201020 }
@@ -1147,7 +1147,7 @@ public function replace(?array $data = null, bool $returnSQL = false)
11471147 return false ;
11481148 }
11491149
1150- if ($ this ->useTimestamps && $ this ->updatedField && ! array_key_exists ($ this ->updatedField , (array ) $ data )) {
1150+ if ($ this ->useTimestamps && $ this ->updatedField !== '' && ! array_key_exists ($ this ->updatedField , (array ) $ data )) {
11511151 $ data [$ this ->updatedField ] = $ this ->setDate ();
11521152 }
11531153
0 commit comments