Class cItemBaseAbstract.

Base class with common features for database based items and item collections.

copyright four for business AG

 Methods

Escape string for using in SQL-Statement.

escape(string $sString) : string

Parameters

$sString

string

The string to escape

Returns

stringEscaped string

Registers a new callback.

register(string $event, mixed $callback, mixed $class) : void
InheritedStatic

Example: cGenericDb::register(cGenericDb::CREATE_SUCCESS, 'itemCreateHandler', 'cApiArticle'); cGenericDb::register(cGenericDb::CREATE_SUCCESS, array('cCallbackHandler', 'executeCreateHandle'), 'cApiArticle');

inherited_from \cGenericDb::register()

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$callback

mixed

Callback to register

$class

mixed

Class name for registering callback (can be string of array with names of the concrete Item classes)

Exceptions

\cInvalidArgumentException if event or class are not set or the callback is not callable

Unregisters all callbacks for a specific event in a class.

unregister(string $event, mixed $class) : void
InheritedStatic

Example: cGenericDb::unregister(cGenericDb::CREATE_SUCCESS, 'cApiArticle');

inherited_from \cGenericDb::unregister()

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$class

mixed

Class name for unregistering callback (can be string of array with names of the concrete Item classes)

Exceptions

\cInvalidArgumentException if the event or the class are not set

Sets some common properties

__construct(string $sTable, string $sPrimaryKey, string $sClassName, int $iLifetime) : void

Parameters

$sTable

string

Name of table

$sPrimaryKey

string

Primary key of table

$sClassName

string

Name of parent class

$iLifetime

int

Lifetime of the object in seconds (NOT USED!)

Exceptions

\cInvalidArgumentException If table name or primary key is not set

Executes all callbacks for a specific event in a class.

_executeCallbacks(string $event, string $class, array $arguments) : void
Inherited
inherited_from \cGenericDb::_executeCallbacks()

Parameters

$event

string

Callback event, must be a valid value of a cGenericDb event constant

$class

string

Class name for executing callback

$arguments

array

Arguments to pass to the callback function

Exceptions

\cInvalidArgumentException if the event or class is not set

Returns properties instance, instantiates it if not done before.

_getPropertiesCollectionInstance() : \cApiPropertyCollection

Returns the second database instance, usable to run additional statements without losing current query results.

_getSecondDBInstance() : \cDb

Returns

 Properties

 

$primaryKey : string
todo remove access from public
 

$virgin : bool

If true, the object is virgin and no operations on it except load-Functions are allowed.

todo remove access from public
 

$_className : string
 

$_oCache : \cItemCache
 

$_settings : array
 

$cache : array
 

$db : \cDb
 

$lasterror : string
 

$lifetime : int
 

$properties : \cApiPropertyCollection
 

$secondDb : \cDb
 

$table : string
 

$_callbacks : array
Inherited
inherited_from \cGenericDb::$$_callbacks

 Constants

 

Callbacks are executed before a item is created.

CREATE_BEFORE 
Inherited

Expected parameters for callback: none

inherited_from \cGenericDb::CREATE_BEFORE
 

Callbacks are executed if item could not be created.

CREATE_FAILURE 
Inherited

Expected parameters for callback: none

inherited_from \cGenericDb::CREATE_FAILURE
 

Callbacks are executed if item could be created successfully.

CREATE_SUCCESS 
Inherited

Expected parameters for callback: ID of created item

inherited_from \cGenericDb::CREATE_SUCCESS
 

Callbacks are executed before deleting an item.

DELETE_BEFORE 
Inherited

Expected parameters for callback: ID of them item to delete

inherited_from \cGenericDb::DELETE_BEFORE
 

Callbacks are executed if deletion of an item fails.

DELETE_FAILURE 
Inherited

Expected parameters for callback: ID of them item to delete

inherited_from \cGenericDb::DELETE_FAILURE
 

Callbacks are executed if item was deleted successfully.

DELETE_SUCCESS 
Inherited

Expected parameters for callback: ID of them item to delete

inherited_from \cGenericDb::DELETE_SUCCESS
 

Callbacks are executed before store process is executed.

STORE_BEFORE 
Inherited

Expected parameters for callback: Item instance

inherited_from \cGenericDb::STORE_BEFORE
 

Callbacks are executed if store process failed.

STORE_FAILURE 
Inherited

This is also likely to happen if query would not change anything in database! Expected parameters for callback: Item instance

inherited_from \cGenericDb::STORE_FAILURE
 

Callbacks are executed if store process saved the values in the database.

STORE_SUCCESS 
Inherited

Expected parameters for callback: Item instance

inherited_from \cGenericDb::STORE_SUCCESS