File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -760,7 +760,7 @@ public function insert($data = null, bool $returnID = true)
760760
761761 // Must be called first, so we don't
762762 // strip out created_at values.
763- $ data = $ this ->doProtectFields ($ data );
763+ $ data = $ this ->doProtectFieldsForInsert ($ data );
764764
765765 // doProtectFields() can further remove elements from
766766 // $data so we need to check for empty dataset again
Original file line number Diff line number Diff line change @@ -129,13 +129,6 @@ class Model extends BaseModel
129129 */
130130 protected $ escape = [];
131131
132- /**
133- * Primary Key value when inserting and useAutoIncrement is false.
134- *
135- * @var int|string|null
136- */
137- private $ tempPrimaryKeyValue ;
138-
139132 /**
140133 * Builder method names that should not be used in the Model.
141134 *
@@ -281,13 +274,6 @@ protected function doInsert(array $data)
281274 $ escape = $ this ->escape ;
282275 $ this ->escape = [];
283276
284- // If $useAutoIncrement is false, add the primary key data.
285- if ($ this ->useAutoIncrement === false && $ this ->tempPrimaryKeyValue !== null ) {
286- $ data [$ this ->primaryKey ] = $ this ->tempPrimaryKeyValue ;
287-
288- $ this ->tempPrimaryKeyValue = null ;
289- }
290-
291277 // Require non-empty primaryKey when
292278 // not using auto-increment feature
293279 if (! $ this ->useAutoIncrement && empty ($ data [$ this ->primaryKey ])) {
@@ -720,14 +706,6 @@ public function insert($data = null, bool $returnID = true)
720706 }
721707 }
722708
723- if ($ this ->useAutoIncrement === false ) {
724- if (is_array ($ data ) && isset ($ data [$ this ->primaryKey ])) {
725- $ this ->tempPrimaryKeyValue = $ data [$ this ->primaryKey ];
726- } elseif (is_object ($ data ) && isset ($ data ->{$ this ->primaryKey })) {
727- $ this ->tempPrimaryKeyValue = $ data ->{$ this ->primaryKey };
728- }
729- }
730-
731709 $ this ->escape = $ this ->tempData ['escape ' ] ?? [];
732710 $ this ->tempData = [];
733711
You can’t perform that action at this time.
0 commit comments