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
string
The table to use as information source
string
The 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
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
int
Number of rowscreateNewItem(string | array $data) : \Item
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.
mixed
Id of entry to delete
bool
deleteBy(string $sField, mixed $mValue) : int
Deletes also cached e entries and any existing properties.
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.
bool
deleteByWhereClause(string $sWhere) : int
Deletes also cached e entries and any existing properties.
string
The where clause of the SQL statement
int
Number 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() |
---|
string
The string to escape
string
Escaped stringexists(mixed $mId) : bool
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.
string
Name of the field to use for the key
mixed
String or array
array
Resulting 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 |
---|
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
array
List of idsgetFieldsByWhereClause(array $aFields, string $sWhere) : array
array
List of fields to get
string
The where clause of the SQL statement
array
List of entries with specified fieldsgetIdsByWhereClause(string $sWhere) : array
string
The where clause of the SQL statement
array
List of idslink(string $sForeignClass) : void
string
The class of foreign table to use
\cInvalidArgumentException |
if the given foreign class does not exist |
---|
loadItem(mixed $mItem) : \Item
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
\Item
bool
The next object, or false if no more objectsquery() : bool
queryAndFetchStructured(array $aObjects) : array
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() |
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)
string
resetQuery()
select(string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Objects are loaded using their primary key.
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)
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() |
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 |
---|
_buildGroupWhereStatements() : array
array
With all where statements_buildWhereStatements() : array
array
With all where statements_delete(mixed $mId) : bool
mixed
Id of entry to delete
bool
_deleteMultiple(array $aIds) : int
array
Id of entries to delete
int
Number of affected records_executeCallbacks(string $event, string $class, array $arguments) : void
inherited_from | \cGenericDb::_executeCallbacks() |
---|---|
inherited_from | \cItemBaseAbstract::_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
todo | Reduce complexity of this function, to much code... |
---|
\???
\cException |
if no join partner could be found |
---|
array
Array 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
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.
string
Specifies 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 |