@@ -619,6 +619,11 @@ public function insert($data = null, bool $returnID = true)
619619 $ this ->tempData = [];
620620 }
621621
622+ if (empty ($ data ))
623+ {
624+ throw DataException::forEmptyDataset ('insert ' );
625+ }
626+
622627 // If $data is using a custom class with public or protected
623628 // properties representing the table elements, we need to grab
624629 // them as an array.
@@ -668,11 +673,6 @@ public function insert($data = null, bool $returnID = true)
668673
669674 $ data = $ this ->trigger ('beforeInsert ' , ['data ' => $ data ]);
670675
671- if (empty ($ data ))
672- {
673- throw DataException::forEmptyDataset ('insert ' );
674- }
675-
676676 // Must use the set() method to ensure objects get converted to arrays
677677 $ result = $ this ->builder ()
678678 ->set ($ data ['data ' ], '' , $ escape )
@@ -749,6 +749,11 @@ public function update($id = null, $data = null): bool
749749 $ this ->tempData = [];
750750 }
751751
752+ if (empty ($ data ))
753+ {
754+ throw DataException::forEmptyDataset ('update ' );
755+ }
756+
752757 // If $data is using a custom class with public or protected
753758 // properties representing the table elements, we need to grab
754759 // them as an array.
@@ -790,11 +795,6 @@ public function update($id = null, $data = null): bool
790795
791796 $ data = $ this ->trigger ('beforeUpdate ' , ['id ' => $ id , 'data ' => $ data ]);
792797
793- if (empty ($ data ))
794- {
795- throw DataException::forEmptyDataset ('update ' );
796- }
797-
798798 $ builder = $ this ->builder ();
799799
800800 if ($ id )
0 commit comments