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

Constructor Function

PropertyCollection() 

_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

changeClient()

changeClient($idclient) 

Parameters

$idclient

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($itemtype, $itemid, $type, $name, $value, $bInternally) 

Parameters

$itemtype

$itemid

$type

$name

$value

$bInternally

delete() Deletes an item in the table.

delete($id) 

Parameters

$id

Delete all properties which match itemtype and itemid

deleteProperties(\itemtype $itemtype, \itemid $itemid) 

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

Delete a property item.

deleteValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name) 

Example:

$properties->deleteValue("idcat", 27, "visual", "image");

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

$type

\type

mixed Type of the data to store (arbitary data)

$name

\name

mixed Entry name

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

Returns all datasets selected by given field and value combination

getAllValues($field, $fieldValue, $auth) : array

Parameters

$field

Field to search in

$fieldValue

Value to search for

$auth

Narrow result down to user in auth objext

Returns

arrayfor each given item

Checks if values for a given item are available.

getProperties(\itemtype $itemtype, \itemid $itemid) : array

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

Returns

arrayfor each given item

Returns the value for a given item.

getValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name, $default) : mixed

Example:

$file = $properties->getValue("idcat", 27, "visual", "image");

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

$type

\type

mixed Type of the data to store (arbitary data)

$name

\name

mixed Entry name

$default

Returns

mixedValue

Returns the value for a given item.

getValuesByType(\itemtype $itemtype, \itemid $itemid, \type $type) : array

Example:

$file = $properties->getValuesByType("idcat", 27, "visual");

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

$type

\type

mixed Type of the data to store (arbitary data)

Returns

arrayValue

loadItem ($item) Loads a single object from the database.

loadItem($vitem) : object
Inherited

Needs to be overridden by the extension class.

inherited_from \ItemCollection::loadItem()

Parameters

$vitem

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

Sets a property item.

setValue(\itemtype $itemtype, \itemid $itemid, \type $type, \name $name, \value $value, \idProp $idProp) 

Handles creation and updating.

Example:

$properties->setValue("idcat", 27, "visual", "image", "images/tool.gif");

Parameters

$itemtype

\itemtype

mixed Type of the item (example: idcat)

$itemid

\itemid

mixed ID of the item (example: 31)

$type

\type

mixed Type of the data to store (arbitary data)

$name

\name

mixed Entry name

$value

\value

mixed Value

$idProp

\idProp

int id of database record (if set, update on this basis (possiblity to update name value and type))

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
 

$client 
 

$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