Property collection
Base class with common features for database based items and item collections.
package | CONTENIDO API |
---|---|
subpackage | Model |
copyright | four for business AG |
ItemCollection($sTable, $sPrimaryKey, $iLifetime)
inherited_from | \ItemCollection::ItemCollection() |
---|
__call(string $name, array $arguments) : mixed
Currently it works as a fallback for the not supported method create() which creates a PHP Strict warning.
inherited_from | \ItemCollection::__call() |
---|
string
array
mixed
__construct() : void
\cInvalidArgumentException |
If table name or primary key is not set |
---|
_getPropertiesFromCache(mixed $itemtype, mixed $itemid) : array
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
array
For each given itemaddResultField(string $sField)
inherited_from | \ItemCollection::addResultField() |
---|
string
changeClient(int $idclient)
int
copyItem(object $srcItem, array $fieldsToOverwrite) : object | \Item | null
inherited_from | \ItemCollection::copyItem() |
---|
object
Source Item instance to copy
array
Assoziative list of fields to overwrite.
\cInvalidArgumentException |
If Item class doesn't match the defined _itemClass property or passed Item instance has no loaded recordset |
---|
count() : int
inherited_from | \ItemCollection::count() |
---|
int
Number of rowscreate(mixed $itemtype, mixed $itemid, mixed $type, mixed $name, mixed $value, bool $bInternally) : \cApiProperty
Example: $proerty = $properties->create('idcat', 27, 'visual', 'image', 'images/tool.gif');
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
mixed
Entry name
mixed
Value
bool
Optionally default false (on internal call do not escape parameters again
createNewItem(string | array $data) : \Item
inherited_from | \ItemCollection::createNewItem() |
---|
string
array
optional parameter for direct input of primary key value (string) or multiple column name - value pairs
\Item
The newly created objectdelete(mixed $mId) : bool
Deletes also cached e entry and any existing properties.
inherited_from | \ItemCollection::delete() |
---|
mixed
Id of entry to delete
bool
deleteBy(string $sField, mixed $mValue) : int
Deletes also cached e entries and any existing properties.
inherited_from | \ItemCollection::deleteBy() |
---|
string
The field name
mixed
The value of the field
int
Number of deleted entriesdeleteByMany($values) : bool
Deletes also cached e entries and any existing properties.
inherited_from | \ItemCollection::deleteByMany() |
---|
bool
deleteByWhereClause(string $sWhere) : int
Deletes also cached e entries and any existing properties.
inherited_from | \ItemCollection::deleteByWhereClause() |
---|
string
The where clause of the SQL statement
int
Number of deleted entriesdeleteProperties(mixed $itemtype, mixed $itemid)
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
deletePropertiesMultiple(mixed $itemtype, array $itemids)
mixed
Type of the item (example: idcat)
array
Ids of multiple items (example: array(31,12,22))
deleteValue(mixed $itemtype, mixed $itemid, mixed $type, mixed $name)
Example: $properties->deleteValue('idcat', 27, 'visual', 'image');
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
mixed
Entry name
deleteWhere(string $sField, mixed $mRestriction, string $sOperator)
inherited_from | \ItemCollection::deleteWhere() |
---|
string
mixed
string
deleteWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator)
inherited_from | \ItemCollection::deleteWhereGroup() |
---|
string
string
mixed
string
escape(string $sString) : string
inherited_from | \cItemBaseAbstract::escape() |
---|---|
inherited_from | \ItemCollection::escape() |
string
The string to escape
string
Escaped stringexists(mixed $mId) : bool
inherited_from | \ItemCollection::exists() |
---|
mixed
The id to check for (could be numeric or string)
bool
True if object exists, false if notfetchArray(string $sKey, mixed $mFields) : array
Example: $i = $object->fetchArray('idartlang', array('idlang', 'name'));
could result in: $i[5] = array('idlang' => 5, 'name' => 'My Article');
Important: If you don't pass an array for fields, the function doesn't create an array.
inherited_from | \ItemCollection::fetchArray() |
---|
string
Name of the field to use for the key
mixed
String or array
array
Resulting arrayfetchById(string | int $id) : \Item
inherited_from | \ItemCollection::fetchById() |
---|
string
int
The primary key of the item to load.
\Item
The loaded itemfetchObject(\Item $sClassName)
fetchTable(array $aFields, array $aObjects)
inherited_from | \ItemCollection::fetchTable() |
---|
flexSelect(string $sDistinct, string $sFrom, string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Objects are loaded using their primary key.
author | HerrB |
---|---|
inherited_from | \ItemCollection::flexSelect() |
string
Specifies if distinct will be added to the SQL statement ($sDistinct !== '' -> DISTINCT)
string
Specifies the additional from clause (e.g. 'con_news_groups AS groups, con_news_groupmembers AS groupmembers').
string
Specifies the where clause.
string
Specifies the group by clause.
string
Specifies the order by clause.
string
Specifies the limit by clause.
bool
True on success, otherwhise falsegetAllIds() : array
inherited_from | \ItemCollection::getAllIds() |
---|
array
List of idsgetAllValues(mixed $field, mixed $fieldValue, \cAuth $auth) : array
mixed
Field to search in
mixed
Value to search for
array
For each given itemgetFieldsByWhereClause(array $aFields, string $sWhere) : array
inherited_from | \ItemCollection::getFieldsByWhereClause() |
---|
array
List of fields to get
string
The where clause of the SQL statement
array
List of entries with specified fieldsgetIdsByWhereClause(string $sWhere) : array
inherited_from | \ItemCollection::getIdsByWhereClause() |
---|
string
The where clause of the SQL statement
array
List of idsgetProperties(mixed $itemtype, mixed $itemid) : array
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
array
For each given itemgetValue(mixed $itemtype, mixed $itemid, mixed $type, mixed $name, $default) : mixed
Example: $value = $properties->getValue('idcat', 27, 'visual', 'image');
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
mixed
Entry name
mixed
ValuegetValuesByType(mixed $itemtype, mixed $itemid, mixed $type) : array
Example: $values = $properties->getValuesByType('idcat', 27, 'visual');
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
array
ValuegetValuesOnlyByTypeName($type, mixed $name) : array
Example: $values = $properties->getValuesOnlyByTypeName('note', 'category');
mixed
Type of the data to store (arbitary data)
array
Valuelink(string $sForeignClass) : void
inherited_from | \ItemCollection::link() |
---|
string
The class of foreign table to use
\cInvalidArgumentException |
if the given foreign class does not exist |
---|
loadItem(mixed $mItem) : \Item
inherited_from | \ItemCollection::loadItem() |
---|
mixed
The primary key of the item to load or a recordset with itemdata (array) to inject to the item object.
\cException |
If item class is not set |
---|
\Item
The newly created objectnext() : \Item | bool
inherited_from | \ItemCollection::next() |
---|
\Item
bool
The next object, or false if no more objectsquery() : bool
inherited_from | \ItemCollection::query() |
---|
\cException |
if no item class has been set |
---|
bool
queryAndFetchStructured(array $aObjects) : array
inherited_from | \ItemCollection::queryAndFetchStructured() |
---|
array
With the correct order of the objects
array
Resultregister(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() |
inherited_from | \ItemCollection::register() |
string
Callback event, must be a valid value of a cGenericDb event constant
mixed
Callback to register
mixed
Class 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 |
---|
removeResultField(string $sField)
inherited_from | \ItemCollection::removeResultField() |
---|
string
reset()
resetQuery()
inherited_from | \ItemCollection::resetQuery() |
---|
select(string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Objects are loaded using their primary key.
inherited_from | \ItemCollection::select() |
---|
string
Specifies the where clause.
string
Specifies the group by clause.
string
Specifies the order by clause.
string
Specifies the limit by clause.
bool
True on success, otherwhise falsesetEncoding(string $sEncoding)
inherited_from | \ItemCollection::setEncoding() |
---|
string
setGroupCondition(string $sGroup1, string $sGroup2, string $sCondition)
inherited_from | \ItemCollection::setGroupCondition() |
---|
string
string
string
setInnerGroupCondition(string $sGroup, string $sCondition)
inherited_from | \ItemCollection::setInnerGroupCondition() |
---|
string
string
setLimit(int $iRowStart, int $iRowCount)
inherited_from | \ItemCollection::setLimit() |
---|
int
int
setOrder(string $order)
g. "fieldname", "fieldname DESC", "fieldname DESC, field2name ASC")
inherited_from | \ItemCollection::setOrder() |
---|
string
setValue(mixed $itemtype, mixed $itemid, mixed $type, mixed $name, mixed $value, int $idProp)
Handles creation and updating. Existing item will be updated, not existing item will be created.
Example: $properties->setValue('idcat', 27, 'visual', 'image', 'images/tool.gif');
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
mixed
Entry name
mixed
Value
int
Id of database record (if set, update on this basis (possiblity to update name value and type))
setWhere(string $sField, mixed $mRestriction, string $sOperator)
inherited_from | \ItemCollection::setWhere() |
---|
string
mixed
string
setWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator)
inherited_from | \ItemCollection::setWhereGroup() |
---|
string
string
mixed
string
unregister(string $event, mixed $class) : void
Example: cGenericDb::unregister(cGenericDb::CREATE_SUCCESS, 'cApiArticle');
inherited_from | \cGenericDb::unregister() |
---|---|
inherited_from | \cItemBaseAbstract::unregister() |
inherited_from | \ItemCollection::unregister() |
string
Callback event, must be a valid value of a cGenericDb event constant
mixed
Class 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 |
---|
_addToCache(\cApiUserProperty $entry)
\cApiUserProperty
_buildGroupWhereStatements() : array
inherited_from | \ItemCollection::_buildGroupWhereStatements() |
---|
array
With all where statements_buildWhereStatements() : array
inherited_from | \ItemCollection::_buildWhereStatements() |
---|
array
With all where statements_delete(mixed $mId) : bool
inherited_from | \ItemCollection::_delete() |
---|
mixed
Id of entry to delete
bool
_deleteFromCache(int $id)
int
_deleteFromCacheMultiple(array $ids)
array
_deleteMultiple(array $aIds) : int
inherited_from | \ItemCollection::_deleteMultiple() |
---|
array
Id of entries to delete
int
Number of affected records_deletePropertiesByIds(array $ids)
Deletes them also from internal cache.
array
_executeCallbacks(string $event, string $class, array $arguments) : void
inherited_from | \cGenericDb::_executeCallbacks() |
---|---|
inherited_from | \cItemBaseAbstract::_executeCallbacks() |
inherited_from | \ItemCollection::_executeCallbacks() |
string
Callback event, must be a valid value of a cGenericDb event constant
string
Class name for executing callback
array
Arguments to pass to the callback function
\cInvalidArgumentException |
if the event or class is not set |
---|
_fetchJoinTables(\??? $ignoreRoot) : array
The returned array has the following format:
array( array(fields), array(tables), array(joins), array(wheres) );
Notes: The table is the table name which needs to be added to the FROM clause The join statement which is inserted after the master table The where statement is combined with all other where statements The fields to select from
inherited_from | \ItemCollection::_fetchJoinTables() |
---|
\???
\cException |
if no join partner could be found |
---|
array
Array structure, see above_findReverseJoinPartner(string $sParentClass, string $sClassName)
inherited_from | \ItemCollection::_findReverseJoinPartner() |
---|
string
string
_getPropertiesCollectionInstance() : \cApiPropertyCollection
inherited_from | \cItemBaseAbstract::_getPropertiesCollectionInstance() |
---|---|
inherited_from | \ItemCollection::_getPropertiesCollectionInstance() |
_getSecondDBInstance() : \cDb
inherited_from | \cItemBaseAbstract::_getSecondDBInstance() |
---|---|
inherited_from | \ItemCollection::_getSecondDBInstance() |
_getValueFromCache(mixed $itemtype, mixed $itemid, mixed $type, mixed $name, $default) : mixed
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
mixed
Entry name
mixed
Value_getValuesByTypeFromCache(mixed $itemtype, mixed $itemid, mixed $type) : array
mixed
Type of the item (example: idcat)
mixed
ID of the item (example: 31)
mixed
Type of the data to store (arbitary data)
array
Value_initializeDriver($bForceInit)
inherited_from | \ItemCollection::_initializeDriver() |
---|
boolean If true, forces the driver to initialize, even if it already exists.
_loadFromCache()
_recursiveStructuredFetch(array $aObjects, array $aResult)
inherited_from | \ItemCollection::_recursiveStructuredFetch() |
---|
_resolveLinks() : array
inherited_from | \ItemCollection::_resolveLinks() |
---|
array
_setItemClass(string $sClassName) : void
inherited_from | \ItemCollection::_setItemClass() |
---|
string
Specifies the classname of item
\cInvalidArgumentException |
if the given class can not be instantiated |
---|
_setJoinPartner(string $sForeignCollectionClass) : void
Important: The class specified by $sForeignCollectionClass needs to be a collection class and has to exist. Define all links in the constructor of your object.
inherited_from | \ItemCollection::_setJoinPartner() |
---|
string
Specifies the foreign class to use
\cInvalidArgumentException |
if the given foreign class can not be instantiated |
---|
_useCache($itemtype, $itemid)
$client : int
$primaryKey : string
inherited_from | \cItemBaseAbstract::$$primaryKey |
---|---|
inherited_from | \ItemCollection::$$primaryKey |
$virgin : bool
If true, the object is virgin and no operations on it except load-Functions are allowed.
inherited_from | \cItemBaseAbstract::$$virgin |
---|---|
inherited_from | \ItemCollection::$$virgin |
$_JoinPartners : array
inherited_from | \ItemCollection::$$_JoinPartners |
---|
$_aOperators : array
inherited_from | \ItemCollection::$$_aOperators |
---|
$_bAllMode : bool
Reduces the number of queries send to the database.
inherited_from | \ItemCollection::$$_bAllMode |
---|
$_cacheItemtypes : array
$_className : string
inherited_from | \cItemBaseAbstract::$$_className |
---|---|
inherited_from | \ItemCollection::$$_className |
$_collectionCache : array
inherited_from | \ItemCollection::$$_collectionCache |
---|
$_enableCache : bool
$_encoding : string
inherited_from | \ItemCollection::$$_encoding |
---|
$_entries : array
$_forwardJoinPartners : array
inherited_from | \ItemCollection::$$_forwardJoinPartners |
---|
$_groupConditions : array
inherited_from | \ItemCollection::$$_groupConditions |
---|
$_innerGroupConditions : array
inherited_from | \ItemCollection::$$_innerGroupConditions |
---|
$_itemClass : string
inherited_from | \ItemCollection::$$_itemClass |
---|
$_iteratorItem : object
inherited_from | \ItemCollection::$$_iteratorItem |
---|
$_oCache : \cItemCache
inherited_from | \cItemBaseAbstract::$$_oCache |
---|---|
inherited_from | \ItemCollection::$$_oCache |
$_resultFields : array
inherited_from | \ItemCollection::$$_resultFields |
---|
$_settings : array
inherited_from | \cItemBaseAbstract::$$_settings |
---|---|
inherited_from | \ItemCollection::$$_settings |
$_whereRestriction : array
inherited_from | \ItemCollection::$$_whereRestriction |
---|
$cache : array
inherited_from | \cItemBaseAbstract::$$cache |
---|---|
inherited_from | \ItemCollection::$$cache |
$lasterror : string
inherited_from | \cItemBaseAbstract::$$lasterror |
---|---|
inherited_from | \ItemCollection::$$lasterror |
$lifetime : int
inherited_from | \cItemBaseAbstract::$$lifetime |
---|---|
inherited_from | \ItemCollection::$$lifetime |
$objects : string
inherited_from | \ItemCollection::$$objects |
---|
$properties : \cApiPropertyCollection
inherited_from | \cItemBaseAbstract::$$properties |
---|---|
inherited_from | \ItemCollection::$$properties |
$secondDb : \cDb
inherited_from | \cItemBaseAbstract::$$secondDb |
---|---|
inherited_from | \ItemCollection::$$secondDb |
$table : string
inherited_from | \cItemBaseAbstract::$$table |
---|---|
inherited_from | \ItemCollection::$$table |
$_callbacks : array
inherited_from | \cGenericDb::$$_callbacks |
---|---|
inherited_from | \cItemBaseAbstract::$$_callbacks |
inherited_from | \ItemCollection::$$_callbacks |
CREATE_BEFORE
Expected parameters for callback: none
inherited_from | \cGenericDb::CREATE_BEFORE |
---|---|
inherited_from | \cItemBaseAbstract::CREATE_BEFORE |
inherited_from | \ItemCollection::CREATE_BEFORE |
CREATE_FAILURE
Expected parameters for callback: none
inherited_from | \cGenericDb::CREATE_FAILURE |
---|---|
inherited_from | \cItemBaseAbstract::CREATE_FAILURE |
inherited_from | \ItemCollection::CREATE_FAILURE |
CREATE_SUCCESS
Expected parameters for callback: ID of created item
inherited_from | \cGenericDb::CREATE_SUCCESS |
---|---|
inherited_from | \cItemBaseAbstract::CREATE_SUCCESS |
inherited_from | \ItemCollection::CREATE_SUCCESS |
DELETE_BEFORE
Expected parameters for callback: ID of them item to delete
inherited_from | \cGenericDb::DELETE_BEFORE |
---|---|
inherited_from | \cItemBaseAbstract::DELETE_BEFORE |
inherited_from | \ItemCollection::DELETE_BEFORE |
DELETE_FAILURE
Expected parameters for callback: ID of them item to delete
inherited_from | \cGenericDb::DELETE_FAILURE |
---|---|
inherited_from | \cItemBaseAbstract::DELETE_FAILURE |
inherited_from | \ItemCollection::DELETE_FAILURE |
DELETE_SUCCESS
Expected parameters for callback: ID of them item to delete
inherited_from | \cGenericDb::DELETE_SUCCESS |
---|---|
inherited_from | \cItemBaseAbstract::DELETE_SUCCESS |
inherited_from | \ItemCollection::DELETE_SUCCESS |
STORE_BEFORE
Expected parameters for callback: Item instance
inherited_from | \cGenericDb::STORE_BEFORE |
---|---|
inherited_from | \cItemBaseAbstract::STORE_BEFORE |
inherited_from | \ItemCollection::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 |
inherited_from | \ItemCollection::STORE_FAILURE |
STORE_SUCCESS
Expected parameters for callback: Item instance
inherited_from | \cGenericDb::STORE_SUCCESS |
---|---|
inherited_from | \cItemBaseAbstract::STORE_SUCCESS |
inherited_from | \ItemCollection::STORE_SUCCESS |