Class ItemCollection Abstract class for database based item collections.
Base class with common features for database based items and item collections.
| copyright | four for business AG |
|---|
ItemCollection($sTable, $sPrimaryKey, $iLifetime)
__call(string $name, array $arguments) : mixed
Currently it works as a fallback for the not supported method create() which creates a PHP Strict warning.
string
array
mixed__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 |
|---|
addResultField(string $sField)
string
copyItem(object $srcItem, array $fieldsToOverwrite) : object | \Item | null
objectSource Item instance to copy
arrayAssoziative 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
intNumber of rowscreateNewItem(string | array $data) : \Item
stringarrayoptional parameter for direct input of primary key value (string) or multiple column name - value pairs
\ItemThe newly created objectdelete(mixed $mId) : bool
Deletes also cached e entry and any existing properties.
mixedId of entry to delete
booldeleteBy(string $sField, mixed $mValue) : int
Deletes also cached e entries and any existing properties.
stringThe field name
mixedThe value of the field
intNumber of deleted entriesdeleteByMany($values) : bool
Deletes also cached e entries and any existing properties.
booldeleteByWhereClause(string $sWhere) : int
Deletes also cached e entries and any existing properties.
stringThe where clause of the SQL statement
intNumber of deleted entriesdeleteWhere(string $sField, mixed $mRestriction, string $sOperator)
string
mixed
string
deleteWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator)
string
string
mixed
string
escape(string $sString) : string
| inherited_from | \cItemBaseAbstract::escape() |
|---|
stringThe string to escape
stringEscaped stringexists(mixed $mId) : bool
mixedThe id to check for (could be numeric or string)
boolTrue 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.
stringName of the field to use for the key
mixedString or array
arrayResulting arrayfetchObject(\Item $sClassName)
\Item
fetchTable(array $aFields, array $aObjects)
flexSelect(string $sDistinct, string $sFrom, string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Objects are loaded using their primary key.
| author | HerrB |
|---|
stringSpecifies if distinct will be added to the SQL statement ($sDistinct !== '' -> DISTINCT)
stringSpecifies the additional from clause (e.g. 'con_news_groups AS groups, con_news_groupmembers AS groupmembers').
stringSpecifies the where clause.
stringSpecifies the group by clause.
stringSpecifies the order by clause.
stringSpecifies the limit by clause.
boolTrue on success, otherwhise falsegetAllIds() : array
arrayList of idsgetFieldsByWhereClause(array $aFields, string $sWhere) : array
arrayList of fields to get
stringThe where clause of the SQL statement
arrayList of entries with specified fieldsgetIdsByWhereClause(string $sWhere) : array
stringThe where clause of the SQL statement
arrayList of idslink(string $sForeignClass) : void
stringThe class of foreign table to use
\cInvalidArgumentException |
if the given foreign class does not exist |
|---|
loadItem(mixed $mItem) : \Item
mixedThe 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 |
|---|
\ItemThe newly created objectnext() : \Item | bool
\ItemboolThe next object, or false if no more objectsquery() : bool
queryAndFetchStructured(array $aObjects) : array
arrayWith the correct order of the objects
arrayResultregister(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 |
|---|
removeResultField(string $sField)
string
resetQuery()
select(string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Objects are loaded using their primary key.
stringSpecifies the where clause.
stringSpecifies the group by clause.
stringSpecifies the order by clause.
stringSpecifies the limit by clause.
boolTrue on success, otherwhise falsesetEncoding(string $sEncoding)
string
setGroupCondition(string $sGroup1, string $sGroup2, string $sCondition)
string
string
string
setInnerGroupCondition(string $sGroup, string $sCondition)
string
string
setLimit(int $iRowStart, int $iRowCount)
int
int
setOrder(string $order)
g. "fieldname", "fieldname DESC", "fieldname DESC, field2name ASC")
string
setWhere(string $sField, mixed $mRestriction, string $sOperator)
string
mixed
string
setWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator)
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() |
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 |
|---|
_buildGroupWhereStatements() : array
arrayWith all where statements_buildWhereStatements() : array
arrayWith all where statements_delete(mixed $mId) : bool
mixedId of entry to delete
bool_deleteMultiple(array $aIds) : int
arrayId of entries to delete
intNumber of affected records_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 |
|---|
_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
| todo | Reduce complexity of this function, to much code... |
|---|
\???
\cException |
if no join partner could be found |
|---|
arrayArray structure, see above_findReverseJoinPartner(string $sParentClass, string $sClassName)
string
string
_getPropertiesCollectionInstance() : \cApiPropertyCollection
| inherited_from | \cItemBaseAbstract::_getPropertiesCollectionInstance() |
|---|
_getSecondDBInstance() : \cDb
_initializeDriver($bForceInit)
boolean If true, forces the driver to initialize, even if it already exists.
_recursiveStructuredFetch(array $aObjects, array $aResult)
_resolveLinks() : array
array_setItemClass(string $sClassName) : void
stringSpecifies 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.
stringSpecifies the foreign class to use
\cInvalidArgumentException |
if the given foreign class can not be instantiated |
|---|
$primaryKey : string
| inherited_from | \cItemBaseAbstract::$$primaryKey |
|---|
$virgin : bool
If true, the object is virgin and no operations on it except load-Functions are allowed.
| inherited_from | \cItemBaseAbstract::$$virgin |
|---|
$_JoinPartners : array
$_aOperators : array
$_bAllMode : bool
Reduces the number of queries send to the database.
$_className : string
| inherited_from | \cItemBaseAbstract::$$_className |
|---|
$_collectionCache : array
$_driver : \cGenericDbDriver
$_encoding : string
$_forwardJoinPartners : array
$_groupConditions : array
$_innerGroupConditions : array
$_itemClass : string
$_iteratorItem : object
$_resultFields : array
$_settings : array
| inherited_from | \cItemBaseAbstract::$$_settings |
|---|
$_whereRestriction : array
$cache : array
| inherited_from | \cItemBaseAbstract::$$cache |
|---|
$lasterror : string
| inherited_from | \cItemBaseAbstract::$$lasterror |
|---|
$lifetime : int
| inherited_from | \cItemBaseAbstract::$$lifetime |
|---|
$objects : 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 |