• Resolved msowah

    (@msowah)


    I have a pod with one field that has a relationship to another table-based pod. The relationship field is a multiselect so an array but whenever I do the below

    $params = array(
    		'limit'   => -1,
    		'orderby' => 't.ID DESC',
    		'select'  => 'company_sectors.post_title as sector,t.*',
    	);
    	$companies = pods( 'companies' )->find($params);
    	while ( $companies->fetch() ) {
    		$company = $companies->data->rows;
    	}
    	return $company;

    the relationship field returns only the first object. How do I resolve this?

    • This topic was modified 2 years, 7 months ago by msowah.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @msowah

    Maybe I’m not following, but why are you accessing the ->data->rows if you are already in the fetch loop?

    Cheers, Jory

    Thread Starter msowah

    (@msowah)

    Hello @keraweb even if I remove that the problem still remains which is the relationship field company_sectors.post_title returns only the first object even though there’s more than one object in it.

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @msowah

    I think this is due to your select query.
    As far as I know you cannot use traversals for select queries.
    You’ll have to use sub-queries for this.

    Can you share the SQL output by adding ?pods_debug_sql=1 to your page URL?

    Cheers, Jory

    Thread Starter msowah

    (@msowah)

    I figured out another way to do it. Thank you so much.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Relationship field not showing all data’ is closed to new replies.