PHP Class GDS\Store

MUST be for a specific Entity Kind (as defined by the Schema or Kind passed in on construction)
Author: Tom Walder ([email protected])
Afficher le fichier Open project: tomwalder/php-gds Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( Schema | string | null $kind_schema = null, Gateway $obj_gateway = null ) Gateway and Schema/Kind can be supplied on construction
beginTransaction ( boolean $bol_cross_group = FALSE ) Begin a transaction
createEntity ( array | null $arr_data = null ) : Entity Create a new instance of this GDS Entity class
delete ( $entities ) : boolean Delete one or more Model objects from the Datastore
fetchAll ( $str_query = null, array | null $arr_params = null ) : Entity[] Fetch Entities (optionally based on a GQL query)
fetchById ( $str_id ) : Entity | null Fetch a single Entity from the Datastore, by it's Key ID
fetchByIds ( array $arr_ids ) : Entity[] Fetch multiple entities by Key ID
fetchByName ( $str_name ) : Entity | null Fetch a single Entity from the Datastore, by it's Key Name
fetchByNames ( array $arr_names ) : Entity | null Fetch one or more Entities from the Datastore, by their Key Name
fetchEntityGroup ( Entity $obj_entity ) : Entity[] Fetch all of the entities in a particular group
fetchOne ( $str_query = null, array | null $arr_params = null ) : Entity Fetch ONE Entity based on a GQL query
fetchPage ( $int_page_size, null $mix_offset = null ) : Entity[] Fetch (a page of) Entities (optionally based on a GQL query)
getCursor ( ) : null | string Get the last result cursor
query ( $str_query, array | null $arr_params = null ) Fetch Entities based on a GQL query
setCursor ( $str_cursor ) Set the query cursor
setEntityClass ( $str_class ) Set the class to use when instantiating new Entity objects
upsert ( $entities ) Write one or more new/changed Entity objects to the Datastore

Méthodes protégées

Méthode Description
buildSchema ( ) : Schema | null Optionally build and return a Schema object describing the data model

Private Methods

Méthode Description
consumeTransaction ( ) : string | null Clear and return the current transaction ID
determineSchema ( Schema | string | null $mix_schema ) : Schema Set up the Schema for the current data model, based on the provided Kind/Schema/buildSchema

Method Details

__construct() public méthode

Gateway and Schema/Kind can be supplied on construction
public __construct ( Schema | string | null $kind_schema = null, Gateway $obj_gateway = null )
$kind_schema Schema | string | null
$obj_gateway Gateway

beginTransaction() public méthode

Begin a transaction
public beginTransaction ( boolean $bol_cross_group = FALSE )
$bol_cross_group boolean

buildSchema() protected méthode

This method is intended to be overridden in any extended Store classes
protected buildSchema ( ) : Schema | null
Résultat Schema | null

createEntity() final public méthode

Create a new instance of this GDS Entity class
final public createEntity ( array | null $arr_data = null ) : Entity
$arr_data array | null
Résultat Entity

delete() public méthode

Delete one or more Model objects from the Datastore
public delete ( $entities ) : boolean
Résultat boolean

fetchAll() public méthode

Fetch Entities (optionally based on a GQL query)
public fetchAll ( $str_query = null, array | null $arr_params = null ) : Entity[]
$str_query
$arr_params array | null
Résultat Entity[]

fetchById() public méthode

Only works for root Entities (i.e. those without parent Entities)
public fetchById ( $str_id ) : Entity | null
$str_id
Résultat Entity | null

fetchByIds() public méthode

Fetch multiple entities by Key ID
public fetchByIds ( array $arr_ids ) : Entity[]
$arr_ids array
Résultat Entity[]

fetchByName() public méthode

Only works for root Entities (i.e. those without parent Entities)
public fetchByName ( $str_name ) : Entity | null
$str_name
Résultat Entity | null

fetchByNames() public méthode

Only works for root Entities (i.e. those without parent Entities)
public fetchByNames ( array $arr_names ) : Entity | null
$arr_names array
Résultat Entity | null

fetchEntityGroup() public méthode

Fetch all of the entities in a particular group
public fetchEntityGroup ( Entity $obj_entity ) : Entity[]
$obj_entity Entity
Résultat Entity[]

fetchOne() public méthode

Fetch ONE Entity based on a GQL query
public fetchOne ( $str_query = null, array | null $arr_params = null ) : Entity
$str_query
$arr_params array | null
Résultat Entity

fetchPage() public méthode

Fetch (a page of) Entities (optionally based on a GQL query)
public fetchPage ( $int_page_size, null $mix_offset = null ) : Entity[]
$int_page_size
$mix_offset null
Résultat Entity[]

getCursor() public méthode

Get the last result cursor
public getCursor ( ) : null | string
Résultat null | string

query() public méthode

Supported parameter types: String, Integer, DateTime, GDS\Entity
public query ( $str_query, array | null $arr_params = null )
$str_query
$arr_params array | null

setCursor() public méthode

Usually before continuing through a paged result set
public setCursor ( $str_cursor )
$str_cursor

setEntityClass() public méthode

Must be GDS\Entity, or a sub-class of it This method is here to maintain backwards compatibility. The Schema is responsible in 2.0+
public setEntityClass ( $str_class )
$str_class

upsert() public méthode

Write one or more new/changed Entity objects to the Datastore
public upsert ( $entities )