Skip to content

Commit

Permalink
Possible fix for #894
Browse files Browse the repository at this point in the history
  • Loading branch information
pglewis committed Jan 3, 2013
1 parent dc05848 commit 1e39783
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions classes/PodsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,19 @@ function traverse_recurse ( $pod, $fields, $joined = 't', $depth = 0, $joined_id
}
}
else {
if ( 'meta' == $pod_data[ 'storage' ] ) {
if ( in_array( $traverse[ 'type' ], $tableless_field_types ) ) {
$the_join = "
LEFT JOIN `@wp_podsrel` AS `{$rel_alias}` ON
`{$rel_alias}`.`field_id` = {$traverse[ 'id' ]}
AND `{$rel_alias}`.`item_id` = `{$joined}`.`id`
LEFT JOIN `{$table_info[ 'table' ]}` AS `{$field_joined}` ON
`{$field_joined}`.`{$table_info[ 'field_id' ]}` = `{$rel_alias}`.`related_item_id`
";

$joined_id = 'id';
}
elseif ( 'meta' == $pod_data[ 'storage' ] ) {
if ( !in_array( $traverse[ 'type' ], $tableless_field_types ) ) {
if ( ( $depth + 2 ) == count( $fields ) ) {
$the_join = "
Expand Down Expand Up @@ -2059,18 +2071,6 @@ function traverse_recurse ( $pod, $fields, $joined = 't', $depth = 0, $joined_id
$joined_id = $table_info[ 'meta_field_id' ];
}
}
elseif ( 'table' == $pod_data[ 'storage' ] && in_array( $traverse[ 'type' ], $tableless_field_types ) ) {
$the_join = "
LEFT JOIN `@wp_podsrel` AS `{$rel_alias}` ON
`{$rel_alias}`.`field_id` = {$traverse[ 'id' ]}
AND `{$rel_alias}`.`item_id` = `{$joined}`.`id`
LEFT JOIN `{$table_info[ 'table' ]}` AS `{$field_joined}` ON
`{$field_joined}`.`{$table_info[ 'field_id' ]}` = `{$rel_alias}`.`related_item_id`
";

$joined_id = 'id';
}
}

$the_join = $this->do_hook( 'traverse_the_join', $the_join, compact( 'pod', 'fields', 'joined', 'depth', 'joined_id', 'params' ) );
Expand Down

0 comments on commit 1e39783

Please sign in to comment.