Class ItemCollection Class for database based item collections

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

 Methods

Constructor Function

ArtSpecCollection() 

Constructor Function Note: Default lifetime is 10 seconds.

ItemCollection(string $table, $primaryKey, $lifetime) 
Inherited
inherited_from \ItemCollection::ItemCollection()

Parameters

$table

string

The table to use as information source

$primaryKey

$lifetime

_buildGroupWhereStatements ()

_buildGroupWhereStatements() : array
Inherited

Builds a where statement out of the setGroupWhere calls

inherited_from \ItemCollection::_buildGroupWhereStatements()

Returns

arraywith all where statements

_buildWhereStatements ()

_buildWhereStatements() : array
Inherited

Builds a where statement out of the setWhere calls

inherited_from \ItemCollection::_buildWhereStatements()

Returns

arraywith all where statements

_fetchJoinTables ()

_fetchJoinTables(\none $ignore_root) : array
Inherited

Fetches all tables which will be joined later on.

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

$ignore_root

\none

Returns

arraysee above

_findReverseJoinPartner()

_findReverseJoinPartner($parentclass, $classname) 
Inherited
inherited_from \ItemCollection::_findReverseJoinPartner()

Parameters

$parentclass

$classname

_initializeDriver: Initializes the driver to use with GenericDB.

_initializeDriver($bForceInit) 
Inherited
inherited_from \ItemCollection::_initializeDriver()

Parameters

$bForceInit

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

_recursiveStructuredFetch()

_recursiveStructuredFetch($objects, $array) 
Inherited
inherited_from \ItemCollection::_recursiveStructuredFetch()

Parameters

$objects

$array

_setItemClass: private method to set the accompanying item object.

_setItemClass(string $classname) : \none
Inherited
inherited_from \ItemCollection::_setItemClass()

Parameters

$classname

string

specifies the classname

Returns

\none

_setJoinPartner: Defines the reverse links for this table.

_setJoinPartner(string $foreignCollectionClass) : \none
Inherited

Important: The class specified by $foreignCollectionClass needs to be a collection class and has to exist Define all links in the constructor of your object

inherited_from \ItemCollection::_setJoinPartner()

Parameters

$foreignCollectionClass

string

Specifies the foreign class to use

Returns

\none

addResultField()

addResultField($field) 
Inherited
inherited_from \ItemCollection::addResultField()

Parameters

$field

count () Returns the amount of returned items

count() : integer
Inherited
inherited_from \ItemCollection::count()

Returns

integerNumber of rows

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

create() 
Inherited
inherited_from \ItemCollection::create()

delete() Deletes an item in the table.

delete($id) 

Parameters

$id

deleteWhere ($field, $restriction, $operator)

deleteWhere($field, $restriction, $operator) 
Inherited

Restricts a query with a where clause

inherited_from \ItemCollection::deleteWhere()

Parameters

$field

$restriction

$operator

deleteWhereGroup ($group, $field, $restriction, $operator)

deleteWhereGroup($group, $field, $restriction, $operator) 
Inherited

Restricts a query with a where clause, groupable

inherited_from \ItemCollection::deleteWhereGroup()

Parameters

$group

$field

$restriction

$operator

exists ($id) Checks if a specific entry exists

exists(integer $id) : boolean
Inherited
inherited_from \ItemCollection::exists()

Parameters

$id

integer

The id to check for

Returns

booleantrue if object exists, false if not

fetchArray() Fetches an array of fields from the database.

fetchArray($key, $fields) : 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

$key

string Name of the field to use for the key

$fields

mixed String or array

Returns

arrayResulting array

fetchObject()

fetchObject($class) 
Inherited
inherited_from \ItemCollection::fetchObject()

Parameters

$class

fetchTable()

fetchTable($fields, $objects) 
Inherited
inherited_from \ItemCollection::fetchTable()

Parameters

$fields

$objects

flexSelect ($distinct = "", $from = "", $where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.

flexSelect(string $distinct, string $from, string $where, string $group_by, string $order_by, string $limit) : array
Inherited

Objects are loaded using their primary key.

author HerrB
inherited_from \ItemCollection::flexSelect()

Parameters

$distinct

string

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

$from

string

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

$where

string

Specifies the where clause.

$group_by

string

Specifies the group by clause.

$order_by

string

Specifies the order by clause.

$limit

string

Specifies the limit by clause.

Returns

arrayArray of DBObject-Objects

Loads an item by its ID (primary key)

loadItem($itemID) : object

Needs to be overridden by the extension class.

Parameters

$itemID

integer Specifies the item ID to load

Returns

objectThe newly created object

next () Advances to the next item in the database.

next() : object
Inherited
inherited_from \ItemCollection::next()

Returns

objectThe next object, or false if no more objects

query()

query() 
Inherited
inherited_from \ItemCollection::query()

fetchStructured Returns an array of arrays

queryAndFetchStructured(\objects $objects) : array
Inherited
inherited_from \ItemCollection::queryAndFetchStructured()

Parameters

$objects

\objects

array with the correct order of the objects

Returns

arrayresult

removeResultField()

removeResultField($field) 
Inherited
inherited_from \ItemCollection::removeResultField()

Parameters

$field

resetQuery()

resetQuery() 
Inherited
inherited_from \ItemCollection::resetQuery()

select ($where = "", $group_by = "", $order_by = "", $limit = "") Selects all entries from the database and returns them as DBObject-objects to the user.

select(string $where, string $group_by, string $order_by, string $limit) : array
Inherited

Objects are loaded using their primary key.

inherited_from \ItemCollection::select()

Parameters

$where

string

Specifies the where clause.

$group_by

string

Specifies the group by clause.

$order_by

string

Specifies the order by clause.

$limit

string

Specifies the limit by clause.

Returns

arrayArray of DBObject-Objects

setEncoding()

setEncoding($sEncoding) 
Inherited
inherited_from \ItemCollection::setEncoding()

Parameters

$sEncoding

setGroupCondition ($group1, $group2, $condition)

setGroupCondition($group1, $group2, $condition) 
Inherited

Defines how groups are linked to each other

inherited_from \ItemCollection::setGroupCondition()

Parameters

$group1

$group2

$condition

setInnerGroupCondition ($group, $condition)

setInnerGroupCondition($group, $condition) 
Inherited

Defines how relations in one group are linked each together

inherited_from \ItemCollection::setInnerGroupCondition()

Parameters

$group

$condition

setLimit()

setLimit($iRowStart, $iRowCount) 
Inherited
inherited_from \ItemCollection::setLimit()

Parameters

$iRowStart

$iRowCount

setOrder()

setOrder($order) 
Inherited
inherited_from \ItemCollection::setOrder()

Parameters

$order

setWhere ($field, $restriction, $operator)

setWhere($field, $restriction, $operator) 
Inherited

Restricts a query with a where clause

inherited_from \ItemCollection::setWhere()

Parameters

$field

$restriction

$operator

setWhereGroup ($group, $field, $restriction, $operator)

setWhereGroup($group, $field, $restriction, $operator) 
Inherited

Restricts a query with a where clause, groupable

inherited_from \ItemCollection::setWhereGroup()

Parameters

$group

$field

$restriction

$operator

 Properties

 

Reverse join partners for this data object

$_JoinPartners : array
Inherited
access private
inherited_from \ItemCollection::$$_JoinPartners
 

Encoding

$_encoding : string
Inherited
access private
inherited_from \ItemCollection::$$_encoding
 

Forward join partners for this data object

$_forwardJoinPartners : array
Inherited
access private
inherited_from \ItemCollection::$$_forwardJoinPartners
 

Group conditions

$_groupConditions : array
Inherited
access private
inherited_from \ItemCollection::$$_groupConditions
 

Inner group conditions

$_innerGroupConditions : array
Inherited
access private
inherited_from \ItemCollection::$$_innerGroupConditions
 

Single item class

$_itemClass : string
Inherited
access private
inherited_from \ItemCollection::$$_itemClass
 

Iterator object for the next() method

$_iteratorItem : object
Inherited
access private
inherited_from \ItemCollection::$$_iteratorItem
 

Result fields for the query

$_resultFields : array
Inherited
access private
inherited_from \ItemCollection::$$_resultFields
 

Where restrictions for the query

$_whereRestriction : array
Inherited
access private
inherited_from \ItemCollection::$$_whereRestriction
 

$cache : array
Inherited
access private
inherited_from \ItemCollection::$$cache
 

$db : object
Inherited
access private
inherited_from \ItemCollection::$$db
 

$lasterror : string
Inherited
access private
inherited_from \ItemCollection::$$lasterror
 

Lifetime in seconds

$lifetime : int
Inherited
access private
inherited_from \ItemCollection::$$lifetime
 

$objects : string
Inherited
access private
inherited_from \ItemCollection::$$objects
 

$primaryKey : string
Inherited
access private
inherited_from \ItemCollection::$$primaryKey
 

Property collection

$properties : array
Inherited
access private
inherited_from \ItemCollection::$$properties
 

$table : string
Inherited
access private
inherited_from \ItemCollection::$$table
 

Is entry virgin?

$virgin : array
Inherited
access private
inherited_from \ItemCollection::$$virgin