@@ -619,6 +619,11 @@ public function insert($data = null, bool $returnID = true)
619
619
$ this ->tempData = [];
620
620
}
621
621
622
+ if (empty ($ data ))
623
+ {
624
+ throw DataException::forEmptyDataset ('insert ' );
625
+ }
626
+
622
627
// If $data is using a custom class with public or protected
623
628
// properties representing the table elements, we need to grab
624
629
// them as an array.
@@ -668,11 +673,6 @@ public function insert($data = null, bool $returnID = true)
668
673
669
674
$ data = $ this ->trigger ('beforeInsert ' , ['data ' => $ data ]);
670
675
671
- if (empty ($ data ))
672
- {
673
- throw DataException::forEmptyDataset ('insert ' );
674
- }
675
-
676
676
// Must use the set() method to ensure objects get converted to arrays
677
677
$ result = $ this ->builder ()
678
678
->set ($ data ['data ' ], '' , $ escape )
@@ -749,6 +749,11 @@ public function update($id = null, $data = null): bool
749
749
$ this ->tempData = [];
750
750
}
751
751
752
+ if (empty ($ data ))
753
+ {
754
+ throw DataException::forEmptyDataset ('update ' );
755
+ }
756
+
752
757
// If $data is using a custom class with public or protected
753
758
// properties representing the table elements, we need to grab
754
759
// them as an array.
@@ -790,11 +795,6 @@ public function update($id = null, $data = null): bool
790
795
791
796
$ data = $ this ->trigger ('beforeUpdate ' , ['id ' => $ id , 'data ' => $ data ]);
792
797
793
- if (empty ($ data ))
794
- {
795
- throw DataException::forEmptyDataset ('update ' );
796
- }
797
-
798
798
$ builder = $ this ->builder ();
799
799
800
800
if ($ id )
0 commit comments