Class ItemCollection Abstract class for database based item collections.

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

author Timo A. Hummel <Timo.Hummel@4fb.de>
author Murat Purc
version 0.2
copyright four for business 2003

 Methods

Constructor

__construct() 

Exceptions

\Contenido_ItemException If table name or primary key is not set

Adds a result field

addResultField(string $sField) 
Inherited

inherited_from \ItemCollection::addResultField()

Parameters

$sField

string

cApiClientCollection()

cApiClientCollection() 

deprecated [2011-03-15] Old constructor function for downwards compatibility

Returns the amount of returned items

count() : int
Inherited

inherited_from \ItemCollection::count()

Returns

intNumber of rows

Creates a new item in the table and loads it afterwards.

create() : \Item
Inherited

inherited_from \ItemCollection::create()

Returns

\ItemThe newly created object

Deletes an item in the table.

delete(mixed $mId) : bool
Inherited

Deletes also cached e entry and any existing properties.

inherited_from \ItemCollection::delete()

Parameters

$mId

mixed

Id of entry to delete

Returns

bool

Deletes all found items in the table matching the passed field and it's value.

deleteBy(string $sField, mixed $mValue) : int
Inherited

Deletes also cached e entries and any existing properties.

inherited_from \ItemCollection::deleteBy()

Parameters

$sField

string

The field name

$mValue

mixed

The value of the field

Returns

intNumber of deleted entries

Deletes all found items in the table matching the rules in the passed where clause.

deleteByWhereClause(string $sWhere) : int
Inherited

Deletes also cached e entries and any existing properties.

inherited_from \ItemCollection::deleteByWhereClause()

Parameters

$sWhere

string

The where clause of the SQL statement

Returns

intNumber of deleted entries

Removes a previous set where clause (@see ItemCollection::setWhere).

deleteWhere(string $sField, mixed $mRestriction, string $sOperator) 
Inherited

inherited_from \ItemCollection::deleteWhere()

Parameters

$sField

string

$mRestriction

mixed

$sOperator

string

Removes a previous set groupable where clause (@see ItemCollection::setWhereGroup).

deleteWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator) 
Inherited

inherited_from \ItemCollection::deleteWhereGroup()

Parameters

$sGroup

string

$sField

string

$mRestriction

mixed

$sOperator

string

Escape string for using in SQL-Statement.

escape(string $sString) : string
Inherited

inherited_from \Contenido_ItemBaseAbstract::escape()
inherited_from \ItemCollection::escape()

Parameters

$sString

string

The string to escape

Returns

stringEscaped string

Checks if a specific entry exists.

exists(mixed $mId) : bool
Inherited

inherited_from \ItemCollection::exists()

Parameters

$mId

mixed

The id to check for (could be numeric or string)

Returns

boolTrue if object exists, false if not

Fetches an array of fields from the database.

fetchArray(string $sKey, mixed $mFields) : array
Inherited

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()

Parameters

$sKey

string

Name of the field to use for the key

$mFields

mixed

String or array

Returns

arrayResulting array

Loads a single entry by it's id.

fetchById(string | int $id) : \Item
Inherited

inherited_from \ItemCollection::fetchById()

Parameters

$id

stringint

The primary key of the item to load.

Returns

\ItemThe loaded item

Fetches the resultset related to current loaded primary key as a object

fetchObject($sClassName) 
Inherited

inherited_from \ItemCollection::fetchObject()

Parameters

$sClassName

Item

fetchTable()

fetchTable(array $aFields, array $aObjects) 
Inherited

inherited_from \ItemCollection::fetchTable()

Parameters

$aFields

$aObjects

Selects all entries from the database. Objects are loaded using their primary key.

flexSelect(string $sDistinct, string $sFrom, string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Inherited

author HerrB
inherited_from \ItemCollection::flexSelect()

Parameters

$sDistinct

string

Specifies if distinct will be added to the SQL statement ($sDistinct !== '' -> DISTINCT)

$sFrom

string

Specifies the additional from clause (e.g. 'con_news_groups AS groups, con_news_groupmembers AS groupmembers').

$sWhere

string

Specifies the where clause.

$sGroupBy

string

Specifies the group by clause.

$sOrderBy

string

Specifies the order by clause.

$sLimit

string

Specifies the limit by clause.

Returns

boolTrue on success, otherwhise false

Returns all clients available in the system

getAccessibleClients() : array

Returns

arrayArray with id and name entries

Returns all clients available in the system

getAvailableClients() : array

Returns

arrayArray with id and name entries

Returns the clientname of the given clientid

getClientname(int $iIdClient) : string

Parameters

$iIdClient

int

Returns

stringClientname if found, or empty string if not.

Returns if the given client has a language

hasLanguageAssigned(int $iIdClient) : bool

Parameters

$iIdClient

int

Returns

booltrue if the client has a language

Loads a single object from the database.

loadItem(mixed $mItem) : \Item
Inherited

inherited_from \ItemCollection::loadItem()

Parameters

$mItem

mixed

The primary key of the item to load or a recordset with itemdata (array) to inject to the item object.

Exceptions

\Contenido_ItemException If item class is not set

Returns

\ItemThe newly created object

Builds and runs the query

query() : bool
Inherited

inherited_from \ItemCollection::query()

Returns

bool

Returns an array of arrays

queryAndFetchStructured(array $aObjects) : array
Inherited

inherited_from \ItemCollection::queryAndFetchStructured()

Parameters

$aObjects

array

With the correct order of the objects

Returns

arrayResult

Removes existing result field

removeResultField(string $sField) 
Inherited

inherited_from \ItemCollection::removeResultField()

Parameters

$sField

string

Resets the properties

resetQuery() 
Inherited

inherited_from \ItemCollection::resetQuery()

Selects all entries from the database. Objects are loaded using their primary key.

select(string $sWhere, string $sGroupBy, string $sOrderBy, string $sLimit) : bool
Inherited

inherited_from \ItemCollection::select()

Parameters

$sWhere

string

Specifies the where clause.

$sGroupBy

string

Specifies the group by clause.

$sOrderBy

string

Specifies the order by clause.

$sLimit

string

Specifies the limit by clause.

Returns

boolTrue on success, otherwhise false

Sets the encoding.

setEncoding(string $sEncoding) 
Inherited

inherited_from \ItemCollection::setEncoding()

Parameters

$sEncoding

string

Defines how groups are linked to each other

setGroupCondition(string $sGroup1, string $sGroup2, string $sCondition) 
Inherited

inherited_from \ItemCollection::setGroupCondition()

Parameters

$sGroup1

string

$sGroup2

string

$sCondition

string

Defines how relations in one group are linked each together

setInnerGroupCondition(string $sGroup, string $sCondition) 
Inherited

inherited_from \ItemCollection::setInnerGroupCondition()

Parameters

$sGroup

string

$sCondition

string

Sets the limit for results

setLimit(int $iRowStart, int $iRowCount) 
Inherited

inherited_from \ItemCollection::setLimit()

Parameters

$iRowStart

int

$iRowCount

int

Sets the result order part of the query (e. g. "fieldname", "fieldname DESC", "fieldname DESC, field2name ASC")

setOrder(string $order) 
Inherited

inherited_from \ItemCollection::setOrder()

Parameters

$order

string

Restricts a query with a where clause

setWhere(string $sField, mixed $mRestriction, string $sOperator) 
Inherited

inherited_from \ItemCollection::setWhere()

Parameters

$sField

string

$mRestriction

mixed

$sOperator

string

Restricts a query with a where clause, groupable

setWhereGroup(string $sGroup, string $sField, mixed $mRestriction, string $sOperator) 
Inherited

inherited_from \ItemCollection::setWhereGroup()

Parameters

$sGroup

string

$sField

string

$mRestriction

mixed

$sOperator

string

Builds a where statement out of the setGroupWhere calls

_buildGroupWhereStatements() : array
Inherited

inherited_from \ItemCollection::_buildGroupWhereStatements()

Returns

arrayWith all where statements

Builds a where statement out of the setWhere calls

_buildWhereStatements() : array
Inherited

inherited_from \ItemCollection::_buildWhereStatements()

Returns

arrayWith all where statements

Deletes an item in the table, deletes also existing cache entries and properties of the item.

_delete(mixed $mId) : bool
Inherited

inherited_from \ItemCollection::_delete()

Parameters

$mId

mixed

Id of entry to delete

Returns

bool

Fetches all tables which will be joined later on.

_fetchJoinTables(\??? $ignoreRoot) : array
Inherited

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()

Parameters

$ignoreRoot

\???

Returns

arrayArray structure, see above

Returns reverse join partner.

_findReverseJoinPartner(string $sParentClass, string $sClassName) 
Inherited

inherited_from \ItemCollection::_findReverseJoinPartner()

Parameters

$sParentClass

string

$sClassName

string

Returns properties instance, instantiates it if not done before.

_getPropertiesCollectionInstance() : \PropertyCollection
Inherited

inherited_from \Contenido_ItemBaseAbstract::_getPropertiesCollectionInstance()
inherited_from \ItemCollection::_getPropertiesCollectionInstance()

Returns

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

_getSecondDBInstance() : \DB_Contenido
Inherited

inherited_from \Contenido_ItemBaseAbstract::_getSecondDBInstance()
inherited_from \ItemCollection::_getSecondDBInstance()

Returns

Initializes the driver to use with GenericDB.

_initializeDriver(\$bForceInit $bForceInit) 
Inherited

inherited_from \ItemCollection::_initializeDriver()

Parameters

$bForceInit

\$bForceInit

boolean If true, forces the driver to initialize, even if it already exists.

_recursiveStructuredFetch()

_recursiveStructuredFetch(array $aObjects, array $aResult) 
Inherited

inherited_from \ItemCollection::_recursiveStructuredFetch()

Parameters

$aObjects

$aResult

Method to set the accompanying item object.

_setItemClass(string $sClassName) : void
Inherited

inherited_from \ItemCollection::_setItemClass()

Parameters

$sClassName

string

Specifies the classname of item

Defines the reverse links for this table.

_setJoinPartner(string $sForeignCollectionClass) : void
Inherited

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()

Parameters

$sForeignCollectionClass

string

Specifies the foreign class to use

 Properties

 

Storage of the primary key

$primaryKey : string
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$primaryKey
inherited_from \ItemCollection::$$primaryKey
 

Checks for the virginity of created objects. If true, the object is virgin and no operations on it except load-Functions are allowed.

$virgin : bool
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$virgin
inherited_from \ItemCollection::$$virgin
 

Reverse join partners for this data object

$_JoinPartners : array
Inherited

inherited_from \ItemCollection::$$_JoinPartners
 

Stores all operators which are supported by GenericDB Unsupported operators are passed trough as-is.

$_aOperators : array
Inherited

inherited_from \ItemCollection::$$_aOperators
 

Flag to select all fields in a query. Reduces the number of queries send to the database.

$_bAllMode : bool
Inherited

inherited_from \ItemCollection::$$_bAllMode
 

Classname of current instance

$_className : string
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$_className
inherited_from \ItemCollection::$$_className
 

List of instances of ItemCollection implementations

$_collectionCache : array
Inherited

inherited_from \ItemCollection::$$_collectionCache
 

GenericDB driver object

$_driver : \gdbDriver
Inherited

inherited_from \ItemCollection::$$_driver
 

Encoding

$_encoding : string
Inherited

inherited_from \ItemCollection::$$_encoding
 

Forward join partners for this data object

$_forwardJoinPartners : array
Inherited

inherited_from \ItemCollection::$$_forwardJoinPartners
 

Group conditions

$_groupConditions : array
Inherited

inherited_from \ItemCollection::$$_groupConditions
 

Inner group conditions

$_innerGroupConditions : array
Inherited

inherited_from \ItemCollection::$$_innerGroupConditions
 

Single item class

$_itemClass : string
Inherited

inherited_from \ItemCollection::$$_itemClass
 

Iterator object for the next() method

$_iteratorItem : object
Inherited

inherited_from \ItemCollection::$$_iteratorItem
 

Item cache instance

$_oCache : \Contenido_ItemCache
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$_oCache
inherited_from \ItemCollection::$$_oCache
 

Result fields for the query

$_resultFields : array
Inherited

inherited_from \ItemCollection::$$_resultFields
 

GenericDB settings, see $cfg['sql']

$_settings : array
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$_settings
inherited_from \ItemCollection::$$_settings
 

Where restrictions for the query

$_whereRestriction : array
Inherited

inherited_from \ItemCollection::$$_whereRestriction
 

Cache the result items FIXME seems to not used, remove it!

$cache : array
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$cache
inherited_from \ItemCollection::$$cache
 

Database instance, contains the database object

$db : \DB_Contenido
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$db
inherited_from \ItemCollection::$$db
 

Storage of the last occured error

$lasterror : string
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$lasterror
inherited_from \ItemCollection::$$lasterror
 

Lifetime of results/created objects? FIXME Not used at the moment!

$lifetime : int
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$lifetime
inherited_from \ItemCollection::$$lifetime
 

Storage of all result items

$objects : string
Inherited

inherited_from \ItemCollection::$$objects
 

Property collection instance

$properties : \PropertyCollection
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$properties
inherited_from \ItemCollection::$$properties
 

Second DB instance, is required for some additional queries without losing an current existing query result.

$secondDb : \DB_Contenido
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$secondDb
inherited_from \ItemCollection::$$secondDb
 

Storage of the source table to use for the information

$table : string
Inherited

inherited_from \Contenido_ItemBaseAbstract::$$table
inherited_from \ItemCollection::$$table