thybag / PHP-SharePoint-Lists-API

A simple PHP API to make working with SharePoint lists easy.
MIT License
184 stars 95 forks source link

Exclude all but function #109

Open frozenshadow opened 8 years ago

frozenshadow commented 8 years ago

First of all, thank you for creating this amazing library :smile: !

Is it possible to create a function that will exclude all fields except some specified ones, like whitelisting? Or is this in some way possible with the existing functions?

thybag commented 8 years ago

Hello,

You can get the API to return specific fields using the fields method on a query (it just takes an array of field names).

For example;

  $sp->query('<list_name>')->fields(array("field_1", "field_2"))->get();
austin350s10 commented 8 years ago

@frozenshadow Are you talking about only returning certain fields in a query instead of the full result including all the meta data? I would like to figure out a way to do this as well.

I thought that using the fields function would only return the fields listed inside the function, but it does not. It just makes sure to pull the fields that were reference which allows you to refer to them in the result by name. Each record still gets returned with a mountain of data that I have no use for.

I am querying a list with over 600 records and it takes forever to query and return results. I am assuming that since there is so much data returned from each record that is why it takes so long. I could be wrong though. Anybody have any insight on how to speed up queries?

frozenshadow commented 8 years ago

@thybag that's exactly what I tried. However I got the exact same result as @austin350s10 is reporting. So my assumption was that the function only made sure that the field would be included (again, like austin is reporting).