Overview

Namespaces

  • Alchemy
    • core
      • query
      • schema
    • dialect
    • engine
    • orm
    • tests
    • util
      • promise
  • PHP

Classes

  • DataMapper
  • DDL
  • ManyToOne
  • OneToMany
  • OneToOne
  • ORMQuery
  • ORMTable
  • ORMTableRef
  • RelatedSet
  • Relationship
  • Session
  • SessionSelect
  • WorkQueue
  • Overview
  • Namespace
  • Class
  • Tree

Class DataMapper

Abstract base class for custom ORM models. this class doesn't actually store any data, it merely acts as an interface between Domain objects and the Session (which actually owns all of the DB records).

Direct known subclasses

Alchemy\tests\Language, Alchemy\tests\UploadedFile
Abstract
Namespace: Alchemy\orm
Located at alchemy/orm/DataMapper.php
Methods summary
public static
# from_session( Alchemy\orm\Session $session, mixed $sessionID )

Instantiate a domain object from the session

Instantiate a domain object from the session

Parameters

$session
Alchemy\orm\Session
$session The database session which owns this record
$sessionID
mixed
$sessionID A pointer to the record for this objects data in the session
public static array
# list_mappers( )

List all subclasses of DataMapper. Only works for classes already loaded by PHP.

List all subclasses of DataMapper. Only works for classes already loaded by PHP.

Returns

array
public static
# register( )

Call immediately after data mapper definition

Call immediately after data mapper definition

public static Alchemy\core\schema\Table
# schema( )

Gen an instance of Table that represents the schema of this domain object.

Gen an instance of Table that represents the schema of this domain object.

Returns

Alchemy\core\schema\Table
public static Alchemy\orm\ORMTableRef
# table( )

Return a table reference for this model

Return a table reference for this model

Returns

Alchemy\orm\ORMTableRef
public static string
# table_name( )

Get the table name for this mapper

Get the table name for this mapper

Returns

string
Table Name
public
# __construct( )

Object constructor.

Object constructor.

public mixed
# __get( string $prop )

Get the value of a column on this object

Get the value of a column on this object

Parameters

$prop
string
$prop

Returns

mixed
public
# __set( string $prop, mixed $value )

Get the value of a column on this object. Nothing is actually written back to the session until {@DataMapper::save()} is called.

Get the value of a column on this object. Nothing is actually written back to the session until {@DataMapper::save()} is called.

Parameters

$prop
string
$prop Column Name
$value
mixed
$value
public string
# __toString( )

String repr of object

String repr of object

Returns

string
protected
# addPersistanceDependancy( Alchemy\orm\DataMapper $obj )

Add an object to the list of objects that must be persisted before this object can be persisted.

Add an object to the list of objects that must be persisted before this object can be persisted.

Parameters

$obj
Alchemy\orm\DataMapper
$obj
public Alchemy\util\promise\Promise
# cascadeForeignKey( Alchemy\orm\DataMapper $child, Alchemy\orm\Relationship $rel )

Automatically apply properties of this object to another's foreign keys according to a Relationship.

Automatically apply properties of this object to another's foreign keys according to a Relationship.

Parameters

$child
Alchemy\orm\DataMapper
$child object to affect
$rel
Alchemy\orm\Relationship
$rel defines what properties to affect on the child

Returns

Alchemy\util\promise\Promise
resolves when FK is cascaded
public array
# getPrimaryKey( )

Return a set of values which represent this object's primary key.

Return a set of values which represent this object's primary key.

Returns

array
public
# getRelatedSet( mixed $name )

Return a related set object by relationship name

Return a related set object by relationship name

public Alchemy\orm\Session
# getSession( )

Return the Session of this object

Return the Session of this object

Returns

Alchemy\orm\Session
public string
# getSessionID( )

Return the ID used to identify this objects record in the Session

Return the ID used to identify this objects record in the Session

Returns

string
public boolean
# isTransient( )

Return true if this model doesn't yet exist in the database

Return true if this model doesn't yet exist in the database

Returns

boolean
public Alchemy\util\promise\Promise
# onDependanciesPersisted( )

Return a promise resolved when all objects that this object references by foreign key have been persisted

Return a promise resolved when all objects that this object references by foreign key have been persisted

Returns

Alchemy\util\promise\Promise
public Alchemy\util\promise\Promise
# onPersisted( )

Return a Promise for when this object is actually persisted, if it is not already.

Return a Promise for when this object is actually persisted, if it is not already.

Returns

Alchemy\util\promise\Promise
resolves to $this when this DataMapper is persisted
public
# rollback( )

Revert all unsaved changed to this model

Revert all unsaved changed to this model

public
# save( boolean $queueUpdate = true )

Save this object's data back to the session. By default this will queue an UPDATE statement to be run on the server as soon as {@Session::commit()} is called.

Save this object's data back to the session. By default this will queue an UPDATE statement to be run on the server as soon as {@Session::commit()} is called.

Parameters

$queueUpdate
boolean
$queueUpdate Default's to true
public
# set( array $map )

Set multiple properties on this object.

Set multiple properties on this object.

Parameters

$map
array
$map [Property => Value, ...]
public
# setSession( Alchemy\orm\Session $session, string $sessionID, mixed $persisted = false )

Set the Session and Session pointer for this object

Set the Session and Session pointer for this object

Parameters

$session
Alchemy\orm\Session
$session Session which owns this object
$sessionID
string
$sessionID Pointer to data record in $session
$persisted
Properties summary
protected static mixed $table_name null
#

Optional: Define the table name here. If left null, the class name will be used

Optional: Define the table name here. If left null, the class name will be used

protected static array $schema_args array()
#
API documentation generated by ApiGen 2.8.0