Question

We need to extract specific fields, no matter if they have data or not.

If I f.ex. want an putput with only the field with external id : 'logo' i am trying this:

 $limit = 10;
 $app_id = xxxxxxx;
 $items = PodioItem::filter($app_id,array('Limit' => $limit,'external_id' => 'logo'));

Within podio not all the fields are filled in, and the result is that we do not get a return value for field 'logo'.

When we don't get a return from field logo - the array output is not structured in a way so we can grab the data we need.

How do we achieve this ?


Added text

Rough Example on print output:

items[0] = Companyname,Logo,Address,Phone,Country (has data in Logo)

items[1] = Companyname,Address,Phone,Country,ContactPerson (no data in Logo)

items[2] = Companyname,Address,Phone,Country

PROBLEMS ARISING

items[2][4] is not existing (but i won't know this)

items[0][2] is Address Field (but i won't know this)

items[1][2] is Phone Field (but i won't know this)

Looking for Company Contact Person [x][4] accross items will end in

[0] = Wrong (country)

[1] = Right data (ContactPerson)

[2] = PHP error

Like in SQL, i would take the coloumn_name_1,coloumn_name_2, etc.. and grab data from only these fields.

Était-ce utile?

La solution

PodioItem objects have a collection of item fields. As you've noted only fields that have values are included (since including empty fields is redundant). As you've noted you can't reliably access the fields by their array offset.

What you should do it access it by field_id or external_id. These are the unique identifiers. You can use the field method on the PodioItem object for this purpose:

$items = PodioItem::filter(...);
foreach ($items['items'] as $item) {
  // Get field with external_id "logo". You can also pass in field_id
  $field = $item->field('logo');

  if ($field) {
    print "Found a logo field!";
  }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top