Reputation: 1047
I am trying to query the google drive using multiple folder ids.
This is my query
$optParams = array(
'pageSize' => 1000
,'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime)'
,[q] => "trashed=false and ('folder-id-1' in parents or 'folder-id-2' in parents or 'folder-id-3' in parents or 'folder-id-4' in parents or 'folder-id-5' in parents)"
);
$service = new \Google_Service_Drive($this->GoogleClient);
$results = $service->files->listFiles($optParams);
But it is only returning files from the first 2 folders
Edit with more details about my query and the results returned. Folder Ids have been anominised.
$fldrs = [];
$fldrs[] = "folder-id-1"; // Toolkit 3 folders (Shared with me)
$fldrs[] = "folder-id-2"; // Untitled folder 1 file (mine)
$fldrs[] = "folder-id-3"; // Logos 14 files (not mine)
$fldrs[] = "folder-id-4"; // Posters (8 files - not mine)
$fldrs[] = "folder-id-5"; // Promo Assets (11 files not mine)
$q = "trashed=false and (";
$MaxFolders = 5;
for ($i=0;$i<$MaxFolders;$i++)
{
if ($i > 0) $q .= " or ";
$q .= "'{$fldrs[$i]}' in parents";
}
$q .= ")";
$optParams = array(
'pageSize' => 1000
,'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime, driveId)'
,q => $q
);
$service = new \Google_Service_Drive($this->GoogleClient);
$results = $service->files->listFiles($optParams);
------
The $optParams (from debug)
array(3) (
[pageSize] => (int) 1000
[fields] => (string) nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime, driveId)
[q] => (string) trashed=false and ('folder-id-1' in parents or 'folder-id-2' in parents or 'folder-id-3' in parents or 'folder-id-4' in parents or 'folder-id-5' in parents)
)
This only returns 5 files (folders 3 and 4, and 3 files : 1 file from folder 2, 1 file from folder 3, 1 file from folder 5)
If I work through and just do the 1st folder, I get 3 folders returned. If I do 2 folders, I get 2 folders and 1 file If I do 3 folders, I get 2 folders and 2 files If I fo 4 folders, I get 2 folders and 2 files (same as doing 3 folders)
If I pick to do just folder 3 (logos) I get all 14 files.
Most files are not my own. they are shared with me.
Upvotes: 0
Views: 361
Reputation: 117271
The parameter isnt an array. Try this.
$optParams = array(
'pageSize' => 1000
,'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime)'
,'q' => "trashed=false and ('folder-id-1' in parents or 'folder-id-2' in parents or 'folder-id-3' in parents or 'folder-id-4' in parents or 'folder-id-5' in parents)"
);
Upvotes: 1