PHP 클래스 Google\Cloud\Datastore\Query\Query

Queries can be created either by using the builder pattern, or by providing a Query when creating this object. Example: use Google\Cloud\ServiceBuilder; $cloud = new ServiceBuilder(); $datastore = $cloud->datastore(); $query = $datastore->query(); $query->kind('Person'); $query->filter('firstName', 'Bob'); $result = $datastore->runQuery($query); Queries can also be constructed using a Query Object: $query = $datastore->query([ 'query' => [ 'kind' => [ [ 'name' => 'People' ] ], 'filter' => [ 'propertyFilter' => [ 'op' => 'EQUAL', 'property' => [ 'name' => 'firstName' ], 'value' => [ 'stringValue': 'Bob' ] ] ] ] ]); $result = $datastore->runQuery($query);
또한 보기: https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#query Query Object Reference
또한 보기: https://cloud.google.com/datastore/docs/concepts/queries Datastore Queries
상속: implements Google\Cloud\Datastore\Query\QueryInterface, use trait Google\Cloud\Datastore\DatastoreTrait
파일 보기 프로젝트 열기: GoogleCloudPlatform/gcloud-php 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( EntityMapper $entityMapper, array $query = [] )
canPaginate ( ) : boolean Indicate that this type does support automatic pagination.
distinctOn ( array | string $property ) : Query The properties to make distinct.
end ( string $cursor ) : Query The ending point for the query results.
filter ( string $property, string $operator, mixed $value ) : Query Add a filter to the query.
hasAncestor ( Key $key ) : Query Query for entities by their ancestors.
jsonSerialize ( )
keysOnly ( ) : Query Set the query to return only keys (no properties).
kind ( array | string $kinds ) : Query Set the Kind to query.
limit ( integer $num ) : Query The number of results to return.
offset ( integer $num ) : Query The number of results to skip.
order ( string $property, string $direction = self::ORDER_DEFAULT ) : Query Specify an order for the query.
projection ( array | string $properties ) : Query Set the Query Projection.
queryKey ( ) : string Return the query_type union field name.
queryObject ( ) : array Return a service-compliant array.
start ( string $cursor ) : Query The starting point for the query results.

비공개 메소드들

메소드 설명
initializeFilter ( ) : void Setup the filter object when the first filter is created.
mapOperator ( string $operator ) : string Convert given operator to API-compatible operator.
propertyName ( string $property ) : array Format a property name.

메소드 상세

__construct() 공개 메소드

public __construct ( EntityMapper $entityMapper, array $query = [] )
$entityMapper Google\Cloud\Datastore\EntityMapper An instance of EntityMapper
$query array [optional] [Query](https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#query)

canPaginate() 공개 메소드

Indicate that this type does support automatic pagination.
public canPaginate ( ) : boolean
리턴 boolean

distinctOn() 공개 메소드

The query results will contain the first result for each distinct combination of values for the given properties (if empty, all results are returned). Example: $query->distinctOn('lastName');
public distinctOn ( array | string $property ) : Query
$property array | string The property or properties to make distinct.
리턴 Query

end() 공개 메소드

Example: $query->end($lastResultCursor);
또한 보기: https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets Cursors, Limits and Offsets
public end ( string $cursor ) : Query
$cursor string The cursor on which to end the result.
리턴 Query

filter() 공개 메소드

If the top-level filter is specified as a propertyFilter, it will be replaced. Any composite filters will be preserved and the new filter will be added. Example: $query->filter('firstName', '=', 'Bob') ->filter('lastName', '=', 'Testguy');
또한 보기: https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#operator_1 Allowed Operators
public filter ( string $property, string $operator, mixed $value ) : Query
$property string The property to filter.
$operator string The operator to use in the filter. A list of allowed operators may be found [here](https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#operator_1). Short comparison operators are provided for convenience and are mapped to their datastore-compatible equivalents. Available short operators are `=`, `<`, `<=`, `>`, and `>=`.
$value mixed The value to check.
리턴 Query

hasAncestor() 공개 메소드

Keys can be provided either via a {@see \Google\Cloud\Datastore\Key} object, or by providing a kind, identifier and (optionally) an identifier type. Example: $key = $datastore->key('Person', 'Bob'); $query->hasAncestor($key); Specifying an identifier type $key = $datastore->key('Robots', '1337', [ 'identifierType' => Key::TYPE_NAME ]); $query->hasAncestor($key);
public hasAncestor ( Key $key ) : Query
$key Google\Cloud\Datastore\Key The ancestor Key instance.
리턴 Query

jsonSerialize() 공개 메소드

public jsonSerialize ( )

keysOnly() 공개 메소드

Example: $query->keysOnly();
public keysOnly ( ) : Query
리턴 Query

kind() 공개 메소드

If empty, returns entities of all kinds. Must be set in order to filter results. While you may supply as many kinds as you wish, datastore currently only accepts one at a time. Example: $query->kind('Person');
public kind ( array | string $kinds ) : Query
$kinds array | string The kind or kinds to return. Only a single kind is currently supported.
리턴 Query

limit() 공개 메소드

Example: $query->limit(50);
또한 보기: https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets Cursors, Limits and Offsets
public limit ( integer $num ) : Query
$num integer The number of results to return.
리턴 Query

offset() 공개 메소드

Example: $query->offset(2);
또한 보기: https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets Cursors, Limits and Offsets
public offset ( integer $num ) : Query
$num integer The number of results to skip.
리턴 Query

order() 공개 메소드

Example: $query->order('birthDate', Query::ORDER_DESCENDING);
또한 보기: https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#Direction Allowed Directions
public order ( string $property, string $direction = self::ORDER_DEFAULT ) : Query
$property string The property to order by.
$direction string The direction to order in.
리턴 Query

projection() 공개 메소드

Accepts an array of properties. If set, only these properties will be returned. Example: $query->projection(['firstName', 'lastName']);
public projection ( array | string $properties ) : Query
$properties array | string The property or properties to include in the result.
리턴 Query

queryKey() 공개 메소드

Return the query_type union field name.
public queryKey ( ) : string
리턴 string

queryObject() 공개 메소드

This method is intended for use internally by the PHP client.
public queryObject ( ) : array
리턴 array

start() 공개 메소드

Example: $query->start($lastResultCursor);
또한 보기: https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets Cursors, Limits and Offsets
public start ( string $cursor ) : Query
$cursor string The cursor on which to start the result.
리턴 Query