Skip to content

Commit ab148e2

Browse files
committed
fix for #513
1 parent 7c8920a commit ab148e2

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

api.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4931,12 +4931,10 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
49314931
if ($belongsTo) {
49324932
$fkValues = $this->getFkEmptyValues($t1, $t2, $records);
49334933
$this->addFkRecords($t2, $fkValues, $params, $db, $newRecords);
4934-
}
4935-
if ($hasMany) {
4934+
} elseif ($hasMany) {
49364935
$pkValues = $this->getPkEmptyValues($t1, $records);
49374936
$this->addPkRecords($t1, $t2, $pkValues, $params, $db, $newRecords);
4938-
}
4939-
if ($hasAndBelongsToMany) {
4937+
} elseif ($hasAndBelongsToMany) {
49404938
$habtmValues = $this->getHabtmEmptyValues($t1, $t2, $t3, $db, $records);
49414939
$this->addFkRecords($t2, $habtmValues->fkValues, $params, $db, $newRecords);
49424940
}
@@ -4946,12 +4944,10 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
49464944
if ($fkValues != null) {
49474945
$this->fillFkValues($t2, $newRecords, $fkValues);
49484946
$this->setFkValues($t1, $t2, $records, $fkValues);
4949-
}
4950-
if ($pkValues != null) {
4947+
} elseif ($pkValues != null) {
49514948
$this->fillPkValues($t1, $t2, $newRecords, $pkValues);
49524949
$this->setPkValues($t1, $t2, $records, $pkValues);
4953-
}
4954-
if ($habtmValues != null) {
4950+
} elseif ($habtmValues != null) {
49554951
$this->fillFkValues($t2, $newRecords, $habtmValues->fkValues);
49564952
$this->setHabtmValues($t1, $t3, $records, $habtmValues);
49574953
}

src/Tqdev/PhpCrudApi/Record/RelationJoiner.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,10 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
107107
if ($belongsTo) {
108108
$fkValues = $this->getFkEmptyValues($t1, $t2, $records);
109109
$this->addFkRecords($t2, $fkValues, $params, $db, $newRecords);
110-
}
111-
if ($hasMany) {
110+
} elseif ($hasMany) {
112111
$pkValues = $this->getPkEmptyValues($t1, $records);
113112
$this->addPkRecords($t1, $t2, $pkValues, $params, $db, $newRecords);
114-
}
115-
if ($hasAndBelongsToMany) {
113+
} elseif ($hasAndBelongsToMany) {
116114
$habtmValues = $this->getHabtmEmptyValues($t1, $t2, $t3, $db, $records);
117115
$this->addFkRecords($t2, $habtmValues->fkValues, $params, $db, $newRecords);
118116
}
@@ -122,12 +120,10 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
122120
if ($fkValues != null) {
123121
$this->fillFkValues($t2, $newRecords, $fkValues);
124122
$this->setFkValues($t1, $t2, $records, $fkValues);
125-
}
126-
if ($pkValues != null) {
123+
} elseif ($pkValues != null) {
127124
$this->fillPkValues($t1, $t2, $newRecords, $pkValues);
128125
$this->setPkValues($t1, $t2, $records, $pkValues);
129-
}
130-
if ($habtmValues != null) {
126+
} elseif ($habtmValues != null) {
131127
$this->fillFkValues($t2, $newRecords, $habtmValues->fkValues);
132128
$this->setHabtmValues($t1, $t3, $records, $habtmValues);
133129
}

0 commit comments

Comments
 (0)