PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Understanding and Constructing Queries

The primary method to request data from the service is by constructing a query. There are query classes for each of the following types:

  • User is used to specify the user whose data is being searched for, and is specified as a username. if no user is provided, "default" will be used instead to indicate the currently authenticated user (if authenticated).

  • Album is used to specify the album which is being searched for, and is specified as either an id, or an album name.

  • Photo is used to specify the photo which is being searched for, and is specified as an id.

A new UserQuery can be constructed as followed:

<?php
$service 
Zend_Gdata_Photos::AUTH_SERVICE_NAME;
$client Zend_Gdata_ClientLogin::getHttpClient($user$pass$service);
$service = new Zend_Gdata_Photos($client);

$query = new Zend_Gdata_Photos_UserQuery();
$query->setUser("sample.user");

for each query, a number of parameters limiting the search can be requested, or specified, with get(Parameter) and set(Parameter), respectively. They are as follows:

  • Projection sets the format of the data returned in the feed, as either "api" or "base". Normally, "api" is desired. The default is "api".

  • Type sets the type of element to be returned, as either "feed" or "entry". The default is "feed".

  • Access sets the visibility of items to be returned, as "all", "public", or "private". The default is "all". Non-public elements will only be returned if the query is searching for the authenticated user.

  • Tag sets a tag filter for returned items. When a tag is set, only items tagged with this value will return.

  • Kind sets the kind of elements to return. When kind is specified, only entries that match this value will be returned.

  • ImgMax sets the maximum image size for entries returned. Only image entries smaller than this value will be returned.

  • Thumbsize sets the thumbsize of entries that are returned. Any retrieved entry will have a thumbsize equal to this value.

  • User sets the user whose data is being searched for. The default is "default".

  • AlbumId sets the id of the album being searched for. This element only applies to album and photo queries. In the case of photo queries, this specifies the album that contains the requested photo. The album id is mutually exclusive with the album's name. Setting one unsets the other.

  • AlbumName sets the name of the album being searched for. This element only applies to the album and photo queries. In the case of photo queries, this specifies the album that contains the requested photo. The album name is mutually exclusive with the album's id. Setting one unsets the other.

  • PhotoId sets the id of the photo being searched for. This element only applies to photo queries.

Zend Framework