ZenMagick 0.9.6


org.zenmagick.database.provider.ZMPdoDatabase

Class ZMPdoDatabase

ZMObject
|
+--ZMPdoDatabase
All Implemented Interfaces:
ZMDatabase

public class ZMPdoDatabase
extends ZMObject

Implementation of the ZenMagick database layer using PDO.

Support for nested transactions via SAVEPOINTs inspired by http://www.kennynet.co.uk/2008/12/02/php-pdo-nested-transactions/.

Author:
DerManoMann
Version:
$Id: ZMPdoDatabase.php 2217 2009-05-11 02:23:06Z dermanomann $

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMPdoDatabase(array conf)

Create a new instance.

Method Summary
void

beginTransaction()

{@inheritDoc} /

void

commit()

{@inheritDoc} /

void

createModel(mixed table, mixed model, mixed mapping)

{@inheritDoc} /

void

getConfig()

{@inheritDoc} /

protected long

getExecutionTime(string start)

Get the elapsed time since $start.

void

getMetaData(mixed table)

{@inheritDoc} /

void

getResource()

{@inheritDoc} /

void

getStats()

{@inheritDoc} /

protected boolean

isNestedTransactions()

Does this instance allow nested transactions?

void

loadModel(mixed table, mixed key, mixed modelClass, mixed mapping)

{@inheritDoc} /

protected A

prepareStatement(string sql, mixed args, array mapping)

Create a prepared statement.

void

query(mixed sql, mixed args, mixed modelClass)

{@inheritDoc} /

void

querySingle(mixed sql, mixed args, mixed modelClass)

{@inheritDoc} /

void

removeModel(mixed table, mixed model, mixed mapping)

{@inheritDoc} /

void

rollback()

{@inheritDoc} /

protected array

translateRow(array row, array mapping)

Translate a given raw database row with the given mapping.

void

update(mixed sql, mixed data)

{@inheritDoc} /

void

updateModel(mixed table, mixed model, mixed mapping)

{@inheritDoc} /

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Constructor Detail

ZMPdoDatabase

public ZMPdoDatabase(array conf)

Create a new instance.

Supports the custom configuration setting persistent (true | false)

.

Parameters:
conf - Configuration properties.

Method Detail

beginTransaction

public void beginTransaction()

/


commit

public void commit()

/


createModel

public void createModel(mixed table, mixed model, mixed mapping)

/


getConfig

public void getConfig()

/


getExecutionTime

protected long getExecutionTime(string start)

Get the elapsed time since $start.

Parameters:
start - The starting time.
Returns:
The time in milliseconds.

getMetaData

public void getMetaData(mixed table)

/


getResource

public void getResource()

/


getStats

public void getStats()

/


isNestedTransactions

protected boolean isNestedTransactions()

Does this instance allow nested transactions?

Returns:
true if nested transactions are supported.

loadModel

public void loadModel(mixed table, mixed key, mixed modelClass, mixed mapping)

/


prepareStatement

protected A prepareStatement(string sql, mixed args, array mapping)

Create a prepared statement.

Parameters:
sql - The initial SQL.
args - The data either as map or ZMObject instance.
mapping - The field mapping.
Returns:
PreparedStatement or null;

query

public void query(mixed sql, mixed args, mixed modelClass)

/


querySingle

public void querySingle(mixed sql, mixed args, mixed modelClass)

/


removeModel

public void removeModel(mixed table, mixed model, mixed mapping)

/


rollback

public void rollback()

/


translateRow

protected array translateRow(array row, array mapping)

Translate a given raw database row with the given mapping.

Parameters:
row - The database row map.
mapping - The mapping (may be null).
Returns:
The mapped row.

update

public void update(mixed sql, mixed data)

/


updateModel

public void updateModel(mixed table, mixed model, mixed mapping)

/


ZenMagick 0.9.6