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])
Show file Open project: tomwalder/php-gds Class Usage Examples

Public Methods

Method 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

Protected Methods

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

Private Methods

Method 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 method

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 method

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

buildSchema() protected method

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

createEntity() final public method

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

delete() public method

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

fetchAll() public method

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
return Entity[]

fetchById() public method

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

fetchByIds() public method

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

fetchByName() public method

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

fetchByNames() public method

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

fetchEntityGroup() public method

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

fetchOne() public method

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
return Entity

fetchPage() public method

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
return Entity[]

getCursor() public method

Get the last result cursor
public getCursor ( ) : null | string
return null | string

query() public method

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 method

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

setEntityClass() public method

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 method

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