4
4
use Tqdev \PhpCrudApi \Column \ReflectionService ;
5
5
use Tqdev \PhpCrudApi \Column \Reflection \ReflectedTable ;
6
6
use Tqdev \PhpCrudApi \Database \GenericDB ;
7
+ use Tqdev \PhpCrudApi \Middleware \Communication \VariableStore ;
7
8
use Tqdev \PhpCrudApi \Record \Condition \ColumnCondition ;
8
9
use Tqdev \PhpCrudApi \Record \Condition \OrCondition ;
9
- use Tqdev \PhpCrudApi \Middleware \Communication \VariableStore ;
10
10
11
11
class RelationJoiner
12
12
{
13
13
14
14
private $ reflection ;
15
+ private $ ordering ;
15
16
private $ columns ;
16
17
17
18
public function __construct (ReflectionService $ reflection , ColumnIncluder $ columns )
@@ -95,7 +96,7 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
95
96
foreach ($ joins ->getKeys () as $ t2Name ) {
96
97
97
98
$ t2 = $ this ->reflection ->getTable ($ t2Name );
98
-
99
+
99
100
$ belongsTo = count ($ t1 ->getFksTo ($ t2 ->getName ())) > 0 ;
100
101
$ hasMany = count ($ t2 ->getFksTo ($ t1 ->getName ())) > 0 ;
101
102
if (!$ belongsTo && !$ hasMany ) {
@@ -113,11 +114,11 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
113
114
if ($ belongsTo ) {
114
115
$ fkValues = $ this ->getFkEmptyValues ($ t1 , $ t2 , $ records );
115
116
$ this ->addFkRecords ($ t2 , $ fkValues , $ params , $ db , $ newRecords );
116
- }
117
+ }
117
118
if ($ hasMany ) {
118
119
$ pkValues = $ this ->getPkEmptyValues ($ t1 , $ records );
119
120
$ this ->addPkRecords ($ t1 , $ t2 , $ pkValues , $ params , $ db , $ newRecords );
120
- }
121
+ }
121
122
if ($ hasAndBelongsToMany ) {
122
123
$ habtmValues = $ this ->getHabtmEmptyValues ($ t1 , $ t2 , $ t3 , $ db , $ records );
123
124
$ this ->addFkRecords ($ t2 , $ habtmValues ->fkValues , $ params , $ db , $ newRecords );
@@ -128,11 +129,11 @@ private function addJoinsForTables(ReflectedTable $t1, PathTree $joins, array &$
128
129
if ($ fkValues != null ) {
129
130
$ this ->fillFkValues ($ t2 , $ newRecords , $ fkValues );
130
131
$ this ->setFkValues ($ t1 , $ t2 , $ records , $ fkValues );
131
- }
132
+ }
132
133
if ($ pkValues != null ) {
133
134
$ this ->fillPkValues ($ t1 , $ t2 , $ newRecords , $ pkValues );
134
135
$ this ->setPkValues ($ t1 , $ t2 , $ records , $ pkValues );
135
- }
136
+ }
136
137
if ($ habtmValues != null ) {
137
138
$ this ->fillFkValues ($ t2 , $ newRecords , $ habtmValues ->fkValues );
138
139
$ this ->setHabtmValues ($ t1 , $ t2 , $ records , $ habtmValues );
0 commit comments