ZenMagick 0.9.6


org.zenmagick.database.provider.ZMZenCartDatabase

Class ZMZenCartDatabase

ZMObject
|
+--ZMZenCartDatabase
All Implemented Interfaces:
ZMDatabase

public class ZMZenCartDatabase
extends ZMObject

Implementation of the ZenMagick database layer using zen-cart's $db.

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

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMZenCartDatabase(array conf)

Create a new instance.

Method Summary
void

beginTransaction()

{@inheritDoc} /

protected string

bindObject(string sql, mixed obj)

Bind object to a given SQL query.

protected string

bindValueList(string sql, string bindName, array values, string type)

Bind a list of values to a given SQL query.

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.

static string

getMappedType(string type)

Optional mappings.

void

getMetaData(mixed table)

{@inheritDoc} /

void

getResource()

{@inheritDoc} /

void

getStats()

{@inheritDoc} /

void

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

{@inheritDoc} /

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

ZMZenCartDatabase

public ZMZenCartDatabase(array conf)

Create a new instance.

Since this is just a wrapper around the existing global $db, the parameters in $conf are ignored.

Parameters:
conf - Configuration properties.

Method Detail

beginTransaction

public void beginTransaction()

/


bindObject

protected string bindObject(string sql, mixed obj)

Bind object to a given SQL query.

This is based on introspection/reflection on the given object and the available getXXX() or isXXX() methods.

SQL label must follow the listed convenctions:

Examples:

Parameters:
sql - The sql to work on.
obj - The data object instance.
Returns:
The updated SQL query.

bindValueList

protected string bindValueList(string sql, string bindName, array values, string type)

Bind a list of values to a given SQL query.

Converts the values in the given array into a comma separated list of the specified type.

Parameters:
sql - The sql query to work on.
bindName - The name to bind the list to.
values - An array of values.
type - The value type; default is 'string'
Returns:
The sql with $bindName replaced with a properly formatted value list.

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.

getMappedType

public static string getMappedType(string type)

Optional mappings.

Allows to use types not supported bb zen-cart, for example boolean.

Parameters:
type - The type.
Returns:
A valid zen-cart data type.

getMetaData

public void getMetaData(mixed table)

/


getResource

public void getResource()

/


getStats

public void getStats()

/


loadModel

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

/


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