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 Session

Acts as a controller between domain objects, the SQL expression language, and the RDBMS Engine layer. Manages queuing of work and transactions

Namespace: Alchemy\orm
Located at alchemy/orm/Session.php
Methods summary
public
# __construct( Alchemy\engine\IEngine $engine )

Object constructor

Object constructor

Parameters

$engine
Alchemy\engine\IEngine
$engine
public Alchemy\util\Promise
# add( Alchemy\orm\DataMapper $obj )

Add a new domain object to the session

Add a new domain object to the session

Parameters

$obj
Alchemy\orm\DataMapper
$obj

Returns

Alchemy\util\Promise
Resolved when INSERT is sent to the database
public
# queueInsert( Alchemy\orm\DataMapper $obj )
public
# commit( )

Commit changed to the database. Will automatically call Alchemy\orm\Session::flush() to send queries to the database then commit the transaction. You should almost always call this instead of Alchemy\orm\Session::flush()

Commit changed to the database. Will automatically call Alchemy\orm\Session::flush() to send queries to the database then commit the transaction. You should almost always call this instead of Alchemy\orm\Session::flush()

public Alchemy\orm\DDL
# ddl( )

Returns a DDL object for this session

Returns a DDL object for this session

Returns

Alchemy\orm\DDL
public Alchemy\engine\IEngine
# engine( )

Return the Engine associated with this session

Return the Engine associated with this session

Returns

Alchemy\engine\IEngine
public array
# execute( string $cls, Query $query )

Execute a query, wrap the results in the given class and return a set.

Execute a query, wrap the results in the given class and return a set.

Parameters

$cls
string
$cls Class Name of a DataMapper subclass
$query
Query
$query Query to execute

Returns

array
Set of Objects
public
# flush( )

Start a new transaction (if one isn't already open), and flushes all pending queries to the RDBMS in the order they were created. Leaves the transaction open for you to commit / rollback.

Start a new transaction (if one isn't already open), and flushes all pending queries to the RDBMS in the order they were created. Leaves the transaction open for you to commit / rollback.

protected array
# getPrimaryKey( string $cls, array $record = array() )

Get the primary key for the given class and record. If one doesn't exist yet, it generates a transient key to be used until the database allocates the object a real key.

Get the primary key for the given class and record. If one doesn't exist yet, it generates a transient key to be used until the database allocates the object a real key.

Parameters

$cls
string
$cls Class Name of a DataMapper subclass
$record
array
$record Data Record

Returns

array
public mixed &
# getProperty( string $cls, mixed $id, string $prop )

Return a reference to the given field

Return a reference to the given field

Parameters

$cls
string
$cls Class Name
$id
mixed
$id Record ID
$prop
string
$prop Column Name

Returns

mixed
public Alchemy\orm\DataMapper
# object( string $cls, string $sid )

Get an object from the session store without running a query.

Get an object from the session store without running a query.

Parameters

$cls
string
$cls DataMapper type
$sid
string
$sid SessionID

Returns

Alchemy\orm\DataMapper
public Alchemy\orm\SessionSelect
# objects( mixed $cls )

Return a SessionSelect for the given class

Return a SessionSelect for the given class

Returns

Alchemy\orm\SessionSelect
public Alchemy\util\Promise
# remove( Alchemy\orm\DataMapper & $obj )

Delete the given object form the database

Delete the given object form the database

Returns

Alchemy\util\Promise
resolved when DELETE statement is run
public Alchemy\util\Promise
# save( string $cls, mixed $id )

Queue an UPDATE query to be run later to update values set with Alchemy\orm\Session::setProperty()

Queue an UPDATE query to be run later to update values set with Alchemy\orm\Session::setProperty()

Parameters

$cls
string
$cls Class Name
$id
mixed
$id Record ID

Returns

Alchemy\util\Promise
Resolved when the query is run
public
# setProperty( string $cls, mixed $id, string $prop, mixed $value )

Update a property value

Update a property value

Parameters

$cls
string
$cls Class Name
$id
mixed
$id Record ID
$prop
string
$prop Column Name
$value
mixed
$value Property Value
public
# updatePrimaryKey( Alchemy\orm\DataMapper $obj, mixed $oldID, mixed $newID )

Accepts an object and moves it from one primary key to a new primary key. This is only ever needed when migrating from a transient key to a real db-allocated key after an INSERT.

Accepts an object and moves it from one primary key to a new primary key. This is only ever needed when migrating from a transient key to a real db-allocated key after an INSERT.

Parameters

$obj
Alchemy\orm\DataMapper
$obj
$oldID
mixed
$oldID
$newID
mixed
$newID
protected
# wrap( string $cls, array $rows )

Wrap a set of rows in the given DataMapper class

Wrap a set of rows in the given DataMapper class

Parameters

$cls
string
$cls Class Name
$rows
array
$rows Two-dimensional array of records
Properties summary
protected mixed $queue
#
protected mixed $engine
#
protected array $records array()
#
protected array $updated array()
#
API documentation generated by ApiGen 2.8.0