File tree 1 file changed +19
-1
lines changed
1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -168,10 +168,28 @@ public function get($key, $id)
168
168
//get 1:0 relations
169
169
$ relations = $ this ->schema ->getRelations (0 );
170
170
foreach ($ relations as $ table => $ relation ) {
171
+ $ schema = $ this ->schema ;
172
+
171
173
$ row = $ this
172
174
->resource
173
175
->search ($ table )
174
- ->innerJoinUsing ($ relation ['name ' ], $ relation ['primary2 ' ])
176
+ ->when (
177
+ //we need to case for post_post for example
178
+ $ relation ['name ' ] === $ this ->schema ->getName (),
179
+ //this is the post_post way
180
+ function () use (&$ schema , &$ relation ) {
181
+ $ on = sprintf (
182
+ '%s = %s ' ,
183
+ $ schema ->getPrimaryFieldName (),
184
+ $ relation ['primary2 ' ]
185
+ );
186
+ $ this ->innerJoinOn ($ relation ['name ' ], $ on );
187
+ },
188
+ //this is the normal way
189
+ function () use (&$ relation , &$ fields ) {
190
+ $ this ->innerJoinUsing ($ relation ['name ' ], $ relation ['primary2 ' ]);
191
+ }
192
+ )
175
193
->addFilter ($ relation ['primary1 ' ] . ' = %s ' , $ id )
176
194
->getRow ();
177
195
You can’t perform that action at this time.
0 commit comments