Skip to content

Commit 0655e73

Browse files
committed
fix bug when create still wants to delete data
1 parent cf12c61 commit 0655e73

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

RelationTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function saveAll()
8181
/* @var $this ActiveRecord */
8282
$db = $this->getDb();
8383
$trans = $db->beginTransaction();
84+
$isNewRecord = $this->isNewRecord;
8485
try {
8586
if ($this->save()) {
8687
$error = 0;
@@ -127,7 +128,7 @@ public function saveAll()
127128
}
128129
$i++;
129130
}
130-
if (!$this->isNewRecord) {
131+
if (!$isNewRecord) {
131132
//DELETE WITH 'NOT IN' PK MODEL & REL MODEL
132133
if ($isManyMany) {
133134
$compiledFields = implode(", ", array_keys($fields));
@@ -170,8 +171,7 @@ public function saveAll()
170171
}
171172
} else {
172173
//No Children left
173-
//echo "No Children left";
174-
if (!$this->isNewRecord) {
174+
if (!$isNewRecord) {
175175
$relData = $this->getRelationData();
176176
foreach ($relData as $rel) {
177177
/* @var $relModel ActiveRecord */

0 commit comments

Comments
 (0)