Class Item Abstract class for database based items.
Base class with common features for database based items and item collections.
| copyright | four for business AG |
|---|
Item($sTable, $sPrimaryKey, $iLifetime)
__construct(string $sTable, string $sPrimaryKey, int $iLifetime) : void
stringThe table to use as information source
stringThe primary key to use
int
\cInvalidArgumentException |
If table name or primary key is not set |
|---|
_inFilter(mixed $mData) : mixed
| see | \setFilters |
|---|---|
| todo | This method is used from public scope, but it should be protected |
mixedData to filter
mixedFiltered datadeleteProperty(string $sType, string $sName) : bool
stringSpecifies the type
stringSpecifies the name
booldeletePropertyById(int $idprop) : bool
intId of property
boolescape(string $sString) : string
| inherited_from | \cItemBaseAbstract::escape() |
|---|
stringThe string to escape
stringEscaped stringget(string $sField) : mixed
stringSpecifies the field to retrieve
mixedValue of the fieldgetField(string $sField) : mixed
stringSpecifies the field to retrieve
mixedValue of the fieldgetMetaObject()
getProperty(string $sType, string $sName) : mixed
stringSpecifies the type
stringSpecifies the name
mixedValue of the given property or falseisLoaded() : bool
boolloadBy(string $sField, mixed $mValue, bool $bSafe) : bool
stringSpecifies the field
mixedSpecifies the value
boolUse inFilter or not
\cException |
if more than one item has been found matching the given arguments |
|---|
boolTrue if the load was successfulloadByMany(array $aAttributes, bool $bSafe) : bool
arrayassociative array with field / value pairs
boolUse inFilter or not
\cException |
if more than one item could be found matching the given arguments |
|---|
boolTrue if the load was successfulloadByPrimaryKey(string $mValue) : bool
stringSpecifies the primary key value
boolTrue if the load was successfulloadByRecordSet(array $aRecordSet)
arrayThe recordset of the item
register(string $event, mixed $callback, mixed $class) : void
Example: cGenericDb::register(cGenericDb::CREATE_SUCCESS, 'itemCreateHandler', 'cApiArticle'); cGenericDb::register(cGenericDb::CREATE_SUCCESS, array('cCallbackHandler', 'executeCreateHandle'), 'cApiArticle');
| inherited_from | \cGenericDb::register() |
|---|---|
| inherited_from | \cItemBaseAbstract::register() |
stringCallback event, must be a valid value of a cGenericDb event constant
mixedCallback to register
mixedClass name for registering callback (can be string of array with names of the concrete Item classes)
\cInvalidArgumentException |
if event or class are not set or the callback is not callable |
|---|
set(string $sField, string $mValue, bool $bSafe)
stringField name
stringValue to set
boolFlag to run defined inFilter on passed value
setField(string $sField, string $mValue, bool $bSafe)
stringField name
stringValue to set
boolFlag to run defined inFilter on passed value
setFilters(array $aInFilters, array $aOutFilters) : void
Examples:
$obj->setFilters(array('addslashes'), array('stripslashes'));
$obj->setFilters(array('htmlencode', 'addslashes'), array('stripslashes', 'htmlencode'));
arrayArray with function names
arrayArray with function names
setProperty(string $sType, string $sName, mixed $mValue) : bool
stringSpecifies the type
stringSpecifies the name
mixedSpecifies the value
boolstore() : bool
booltoArray() : array | false
arrayfalse
unregister(string $event, mixed $class) : void
Example: cGenericDb::unregister(cGenericDb::CREATE_SUCCESS, 'cApiArticle');
| inherited_from | \cGenericDb::unregister() |
|---|---|
| inherited_from | \cItemBaseAbstract::unregister() |
stringCallback event, must be a valid value of a cGenericDb event constant
mixedClass name for unregistering callback (can be string of array with names of the concrete Item classes)
\cInvalidArgumentException |
if the event or the class are not set |
|---|
_executeCallbacks(string $event, string $class, array $arguments) : void
| inherited_from | \cGenericDb::_executeCallbacks() |
|---|---|
| inherited_from | \cItemBaseAbstract::_executeCallbacks() |
stringCallback event, must be a valid value of a cGenericDb event constant
stringClass name for executing callback
arrayArguments to pass to the callback function
\cInvalidArgumentException |
if the event or class is not set |
|---|
_getPropertiesCollectionInstance() : \cApiPropertyCollection
| inherited_from | \cItemBaseAbstract::_getPropertiesCollectionInstance() |
|---|
_getSecondDBInstance() : \cDb
_loadByWhereClause(string $sWhere) : bool
This function is expensive, since it executes allways a query to the database to retrieve the primary key, even if the record set is aleady cached. NOTE: Passed value has to be escaped before. This will not be done by this function.
stringThe where clause like 'idart = 123 AND idlang = 1'
\cException |
if more than one item could be found matching the given where clause |
|---|
boolTrue if the load was successful_onLoad() : void
Inherited classes should override this function if desired.
_outFilter(mixed $mData) : mixed
_setMetaObject($sObjectName)
$primaryKey : string
| inherited_from | \cItemBaseAbstract::$$primaryKey |
|---|
$values : array
$virgin : bool
If true, the object is virgin and no operations on it except load-Functions are allowed.
| inherited_from | \cItemBaseAbstract::$$virgin |
|---|
$_arrInFilters : array
$_arrOutFilters : array
$_className : string
| inherited_from | \cItemBaseAbstract::$$_className |
|---|
$_settings : array
| inherited_from | \cItemBaseAbstract::$$_settings |
|---|
$cache : array
| inherited_from | \cItemBaseAbstract::$$cache |
|---|
$lasterror : string
| inherited_from | \cItemBaseAbstract::$$lasterror |
|---|
$lifetime : int
| inherited_from | \cItemBaseAbstract::$$lifetime |
|---|
$modifiedValues : array
$oldPrimaryKey : string
$table : string
| inherited_from | \cItemBaseAbstract::$$table |
|---|
$_callbacks : array
| inherited_from | \cGenericDb::$$_callbacks |
|---|---|
| inherited_from | \cItemBaseAbstract::$$_callbacks |
CREATE_BEFORE
Expected parameters for callback: none
| inherited_from | \cGenericDb::CREATE_BEFORE |
|---|---|
| inherited_from | \cItemBaseAbstract::CREATE_BEFORE |
CREATE_FAILURE
Expected parameters for callback: none
| inherited_from | \cGenericDb::CREATE_FAILURE |
|---|---|
| inherited_from | \cItemBaseAbstract::CREATE_FAILURE |
CREATE_SUCCESS
Expected parameters for callback: ID of created item
| inherited_from | \cGenericDb::CREATE_SUCCESS |
|---|---|
| inherited_from | \cItemBaseAbstract::CREATE_SUCCESS |
DELETE_BEFORE
Expected parameters for callback: ID of them item to delete
| inherited_from | \cGenericDb::DELETE_BEFORE |
|---|---|
| inherited_from | \cItemBaseAbstract::DELETE_BEFORE |
DELETE_FAILURE
Expected parameters for callback: ID of them item to delete
| inherited_from | \cGenericDb::DELETE_FAILURE |
|---|---|
| inherited_from | \cItemBaseAbstract::DELETE_FAILURE |
DELETE_SUCCESS
Expected parameters for callback: ID of them item to delete
| inherited_from | \cGenericDb::DELETE_SUCCESS |
|---|---|
| inherited_from | \cItemBaseAbstract::DELETE_SUCCESS |
STORE_BEFORE
Expected parameters for callback: Item instance
| inherited_from | \cGenericDb::STORE_BEFORE |
|---|---|
| inherited_from | \cItemBaseAbstract::STORE_BEFORE |
STORE_FAILURE
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 |
|---|---|
| inherited_from | \cItemBaseAbstract::STORE_FAILURE |
STORE_SUCCESS
Expected parameters for callback: Item instance
| inherited_from | \cGenericDb::STORE_SUCCESS |
|---|---|
| inherited_from | \cItemBaseAbstract::STORE_SUCCESS |