0

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.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
Niels
  • 635
  • 3
  • 9
  • 23

1 Answers1

1

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!";
  }
}
  • Hi Andreas. I got your answer. It is great to have your response to my questions no doubt. I though hit a problem that the amount of data i need to process is quite big. I see that you state in your documentation, that caching should be applied where ever possible.Is it possible to limit the data amount that is received if we still want to receive the full data set.. just limited amount of data ? – Niels Feb 17 '14 at 21:12