Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • ArticleForum
  • cApiShortUrl
  • cGenericDb
  • cGenericDbDriver
  • cGenericDbDriverMysql
  • cItemBaseAbstract
  • cItemCache
  • Item
  • ItemCollection
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class ItemCollection

Class ItemCollection Abstract class for database based item collections.

cGenericDb
Extended by cItemBaseAbstract
Extended by ItemCollection

Direct known subclasses

ArticleForumCollection, cApiActionCollection, cApiCategoryTreeCollection, cApiClientCollection, cApiClientLanguageCollection, cApiCommunicationCollection, cApiContainerCollection, cApiContainerConfigurationCollection, cApiContentCollection, cApiDbfsCollection, cApiFileCollection, cApiFileInformationCollection, cApiActionlogCollection, cApiFrameFileCollection, cApiFrontendGroupCollection, cApiFrontendGroupMemberCollection, cApiFrontendPermissionCollection, cApiFrontendUserCollection, cApiGroupCollection, cApiGroupMemberCollection, cApiGroupPropertyCollection, cApiInUseCollection, cApiIso3166Collection, cApiAreaCollection, cApiIso6392Collection, cApiKeywordCollection, cApiLanguageCollection, cApiLayoutCollection, cApiMailLogCollection, cApiMailLogSuccessCollection, cApiMetaTagCollection, cApiMetaTypeCollection, cApiModuleCollection, cApiNavMainCollection, cApiArticleCollection, cApiNavSubCollection, cApiOnlineUserCollection, cApiPathresolveCacheCollection, cApiPropertyCollection, cApiRightCollection, cApiShortUrlCollection, cApiStatCollection, cApiSystemPropertyCollection, cApiTemplateCollection, cApiTemplateConfigurationCollection, cApiArticleLanguageCollection, cApiTypeCollection, cApiUploadCollection, cApiUploadMetaCollection, cApiUserCollection, cApiUserPropertyCollection, NewsletterCollection, NewsletterJobCollection, NewsletterLogCollection, NewsletterRecipientCollection, NewsletterRecipientGroupCollection, cApiArticleSpecificationCollection, NewsletterRecipientGroupMemberCollection, PifaFieldCollection, PifaFormCollection, PimPluginCollection, PimPluginRelationsCollection, WorkflowActions, WorkflowAllocations, WorkflowArtAllocations, WorkflowItems, Workflows, cApiCategoryArticleCollection, WorkflowTasks, WorkflowUserSequences, cApiCategoryCollection, cApiCategoryLanguageCollection

Indirect known subclasses

NoteCollection, TODOCollection
Abstract
Package: Core\GenericDB
Copyright: four for business AG <www.4fb.de>
License: http://www.contenido.org/license/LIZENZ.txt
Author: Timo Hummel
Author: Murat Purc <murat@purc.de>
Located at classes/genericdb/class.item.collection.php
Methods summary
public
# __construct( string $sTable, string $sPrimaryKey )

Constructor Function

Constructor Function

Parameters

$sTable
string
$sTable The table to use as information source
$sPrimaryKey
string
$sPrimaryKey The primary key to use

Throws

cInvalidArgumentException
If table name or primary key is not set

Overrides

cItemBaseAbstract::__construct()
public
# ItemCollection( mixed $sTable, mixed $sPrimaryKey, mixed $iLifetime = 10 )

Constructor function for downwards compatibility

Constructor function for downwards compatibility

protected
# _setJoinPartner( string $sForeignCollectionClass )

Defines the reverse links for this table.

Defines the reverse links for this table.

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.

Parameters

$sForeignCollectionClass
string
$sForeignCollectionClass Specifies the foreign class to use

Throws

cInvalidArgumentException
if the given foreign class can not be instantiated
protected
# _setItemClass( string $sClassName )

Method to set the accompanying item object.

Method to set the accompanying item object.

Parameters

$sClassName
string
$sClassName Specifies the classname of item

Throws

cInvalidArgumentException
if the given class can not be instantiated
protected
# _initializeDriver( mixed $bForceInit = false )

Initializes the driver to use with GenericDB.

Initializes the driver to use with GenericDB.

Parameters

$bForceInit
mixed
$bForceInit boolean If true, forces the driver to initialize, even if it already exists.
public
# setEncoding( string $sEncoding )

Sets the encoding.

Sets the encoding.

Parameters

$sEncoding
string
$sEncoding
public
# link( string $sForeignClass )

Sets the query to use foreign tables in the resultset

Sets the query to use foreign tables in the resultset

Parameters

$sForeignClass
string
$sForeignClass The class of foreign table to use

Throws

cInvalidArgumentException
if the given foreign class does not exist
public
# setLimit( integer $iRowStart, integer $iRowCount )

Sets the limit for results

Sets the limit for results

Parameters

$iRowStart
integer
$iRowStart
$iRowCount
integer
$iRowCount
public
# setWhere( string $sField, mixed $mRestriction, string $sOperator = '=' )

Restricts a query with a where clause

Restricts a query with a where clause

Parameters

$sField
string
$sField
$mRestriction
mixed
$mRestriction
$sOperator
string
$sOperator
public
# deleteWhere( string $sField, mixed $mRestriction, string $sOperator = '=' )

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

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

Parameters

$sField
string
$sField
$mRestriction
mixed
$mRestriction
$sOperator
string
$sOperator
public
# setWhereGroup( string $sGroup, string $sField, mixed $mRestriction, string $sOperator = '=' )

Restricts a query with a where clause, groupable

Restricts a query with a where clause, groupable

Parameters

$sGroup
string
$sGroup
$sField
string
$sField
$mRestriction
mixed
$mRestriction
$sOperator
string
$sOperator
public
# deleteWhereGroup( string $sGroup, string $sField, mixed $mRestriction, string $sOperator = '=' )

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

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

Parameters

$sGroup
string
$sGroup
$sField
string
$sField
$mRestriction
mixed
$mRestriction
$sOperator
string
$sOperator
public
# setInnerGroupCondition( string $sGroup, string $sCondition = 'AND' )

Defines how relations in one group are linked each together

Defines how relations in one group are linked each together

Parameters

$sGroup
string
$sGroup
$sCondition
string
$sCondition
public
# setGroupCondition( string $sGroup1, string $sGroup2, string $sCondition = 'AND' )

Defines how groups are linked to each other

Defines how groups are linked to each other

Parameters

$sGroup1
string
$sGroup1
$sGroup2
string
$sGroup2
$sCondition
string
$sCondition
protected array
# _buildGroupWhereStatements( )

Builds a where statement out of the setGroupWhere calls

Builds a where statement out of the setGroupWhere calls

Returns

array
With all where statements
protected array
# _buildWhereStatements( )

Builds a where statement out of the setWhere calls

Builds a where statement out of the setWhere calls

Returns

array
With all where statements
protected array
# _fetchJoinTables( )

Fetches all tables which will be joined later on.

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

Returns

array
Array structure, see above

Throws

cException
if no join partner could be found
protected array
# _resolveLinks( )

Resolves links (class names of joined partners)

Resolves links (class names of joined partners)

Returns

array
public
# resetQuery( )

Resets the properties

Resets the properties

public boolean
# query( )

Builds and runs the query

Builds and runs the query

Returns

boolean

Throws

cException
if no item class has been set
public
# setOrder( string $order )

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

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

Parameters

$order
string
$order
public
# addResultField( string $sField )

Adds a result field

Adds a result field

Parameters

$sField
string
$sField
public
# removeResultField( string $sField )

Removes existing result field

Removes existing result field

Parameters

$sField
string
$sField
protected
# _findReverseJoinPartner( string $sParentClass, string $sClassName )

Returns reverse join partner.

Returns reverse join partner.

Parameters

$sParentClass
string
$sParentClass
$sClassName
string
$sClassName
public boolean
# select( string $sWhere = '', string $sGroupBy = '', string $sOrderBy = '', string $sLimit = '' )

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

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

Parameters

$sWhere
string
$sWhere Specifies the where clause.
$sGroupBy
string
$sGroupBy Specifies the group by clause.
$sOrderBy
string
$sOrderBy Specifies the order by clause.
$sLimit
string
$sLimit Specifies the limit by clause.

Returns

boolean
True on success, otherwhise false
public boolean
# flexSelect( string $sDistinct = '', string $sFrom = '', string $sWhere = '', string $sGroupBy = '', string $sOrderBy = '', string $sLimit = '' )

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

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

Parameters

$sDistinct
string
$sDistinct Specifies if distinct will be added to the SQL statement ($sDistinct !== '' -> DISTINCT)
$sFrom
string
$sFrom Specifies the additional from clause (e.g. 'con_news_groups AS groups, con_news_groupmembers AS groupmembers').
$sWhere
string
$sWhere Specifies the where clause.
$sGroupBy
string
$sGroupBy Specifies the group by clause.
$sOrderBy
string
$sOrderBy Specifies the order by clause.
$sLimit
string
$sLimit Specifies the limit by clause.

Returns

boolean
True on success, otherwhise false
public boolean
# exists( mixed $mId )

Checks if a specific entry exists.

Checks if a specific entry exists.

Parameters

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

Returns

boolean
True if object exists, false if not
public Item
# next( )

Advances to the next item in the database.

Advances to the next item in the database.

Returns

Item
bool next object, or false if no more objects
public
# fetchObject( Item $sClassName )

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

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

Parameters

$sClassName
Item
public
# fetchTable( array $aFields = array(), array $aObjects = array() )

Prelimary documentation $aFields = array with the fields to fetch. Notes: If the array contains keys, the key will be used as alias for the field. Example: array('id' => 'idcat') will put 'idcat' into field 'id' $aObjects = array with the objects to fetch. Notes: If the array contains keys, the key will be used as alias for the object. If you specify more than one object with the same key, the array will be multi-dimensional.

Prelimary documentation $aFields = array with the fields to fetch. Notes: If the array contains keys, the key will be used as alias for the field. Example: array('id' => 'idcat') will put 'idcat' into field 'id' $aObjects = array with the objects to fetch. Notes: If the array contains keys, the key will be used as alias for the object. If you specify more than one object with the same key, the array will be multi-dimensional.

public array
# queryAndFetchStructured( array $aObjects )

Returns an array of arrays

Returns an array of arrays

Parameters

$aObjects
array
$aObjects With the correct order of the objects

Returns

array
Result
protected
# _recursiveStructuredFetch( array $aObjects, array $aResult )
public integer
# count( )

Returns the amount of returned items

Returns the amount of returned items

Returns

integer
Number of rows
public Item
# fetchById( string|integer $id )

Loads a single entry by it's id.

Loads a single entry by it's id.

Parameters

$id
string|integer
$id The primary key of the item to load.

Returns

Item
The loaded item
public Item
# loadItem( mixed $mItem )

Loads a single object from the database.

Loads a single object from the database.

Parameters

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

Returns

Item
The newly created object

Throws

cException
If item class is not set
public Item
# createNewItem( string|array $data = NULL )

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

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

Parameters

$data
string|array
$data optional parameter for direct input of primary key value (string) or multiple column name - value pairs

Returns

Item
The newly created object
public object
# copyItem( object $srcItem, array $fieldsToOverwrite = array() )

Inserts a new item entry by using a existing item entry.

Inserts a new item entry by using a existing item entry.

Parameters

$srcItem
object
$srcItem Source Item instance to copy
$fieldsToOverwrite
array
$fieldsToOverwrite Assoziative list of fields to overwrite.

Returns

object
Item null

Throws

cInvalidArgumentException
If Item class doesn't match the defined _itemClass property or passed Item instance has no loaded recordset
public array
# getIdsByWhereClause( string $sWhere )

Returns all ids of recordsets in the table matching the rules in the passed where clause.

Returns all ids of recordsets in the table matching the rules in the passed where clause.

Parameters

$sWhere
string
$sWhere The where clause of the SQL statement

Returns

array
List of ids
public array
# getFieldsByWhereClause( array $aFields, string $sWhere )

Returns all specified fields of recordsets in the table matching the rules in the passed where clause.

Returns all specified fields of recordsets in the table matching the rules in the passed where clause.

Parameters

$aFields
array
$aFields List of fields to get
$sWhere
string
$sWhere The where clause of the SQL statement

Returns

array
List of entries with specified fields
public array
# getAllIds( )

Returns all ids of recordsets in the table.

Returns all ids of recordsets in the table.

Returns

array
List of ids
public boolean
# delete( mixed $mId )

Deletes an item in the table. Deletes also cached e entry and any existing properties.

Deletes an item in the table. Deletes also cached e entry and any existing properties.

Parameters

$mId
mixed
$mId Id of entry to delete

Returns

boolean
public integer
# deleteByWhereClause( string $sWhere )

Deletes all found items in the table matching the rules in the passed where clause. Deletes also cached e entries and any existing properties.

Deletes all found items in the table matching the rules in the passed where clause. Deletes also cached e entries and any existing properties.

Parameters

$sWhere
string
$sWhere The where clause of the SQL statement

Returns

integer
Number of deleted entries
public integer
# deleteBy( string $sField, mixed $mValue )

Deletes all found items in the table matching the passed field and it's value. Deletes also cached e entries and any existing properties.

Deletes all found items in the table matching the passed field and it's value. Deletes also cached e entries and any existing properties.

Parameters

$sField
string
$sField The field name
$mValue
mixed
$mValue The value of the field

Returns

integer
Number of deleted entries
protected boolean
# _delete( mixed $mId )

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

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

Parameters

$mId
mixed
$mId Id of entry to delete

Returns

boolean
protected integer
# _deleteMultiple( array $aIds )

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

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

Parameters

$aIds
array
$aIds Id of entries to delete

Returns

integer
Number of affected records
public array
# fetchArray( string $sKey, mixed $mFields )

Fetches an array of fields from the database.

Fetches an array of fields from the database.

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.

Parameters

$sKey
string
$sKey Name of the field to use for the key
$mFields
mixed
$mFields String or array

Returns

array
Resulting array
Methods inherited from cItemBaseAbstract
_getPropertiesCollectionInstance(), _getSecondDBInstance(), escape()
Methods inherited from cGenericDb
_executeCallbacks(), register(), unregister()
Constants inherited from cGenericDb
CREATE_BEFORE, CREATE_FAILURE, CREATE_SUCCESS, DELETE_BEFORE, DELETE_FAILURE, DELETE_SUCCESS, STORE_BEFORE, STORE_FAILURE, STORE_SUCCESS
Properties summary
protected string $objects
#

Storage of all result items

Storage of all result items

protected cGenericDbDriver $_driver
#

GenericDB driver object

GenericDB driver object

protected array $_collectionCache array()
#

List of instances of ItemCollection implementations

List of instances of ItemCollection implementations

protected string $_itemClass
#

Single item class

Single item class

protected object $_iteratorItem
#

Iterator object for the next() method

Iterator object for the next() method

protected array $_JoinPartners array()
#

Reverse join partners for this data object

Reverse join partners for this data object

protected array $_forwardJoinPartners
#

Forward join partners for this data object

Forward join partners for this data object

protected array $_whereRestriction
#

Where restrictions for the query

Where restrictions for the query

protected array $_innerGroupConditions array()
#

Inner group conditions

Inner group conditions

protected array $_groupConditions
#

Group conditions

Group conditions

protected array $_resultFields array()
#

Result fields for the query

Result fields for the query

protected string $_encoding
#

Encoding

Encoding

protected object $_itemClassInstance
#

Item class instance

Item class instance

protected array $_aOperators
#

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

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

protected boolean $_bAllMode false
#

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

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

protected array $_where
#

Array with where conditions

Array with where conditions

protected string $_order
#

Order mode with direction

Order mode with direction

protected integer $_limitStart
#

Starting limit

Starting limit

protected integer $_limitCount
#

Amount of items for limit

Amount of items for limit

protected string $_lastSQL
#

Last SQL statement

Last SQL statement

protected array $_links
#

Array with linked tables

Array with linked tables

Properties inherited from cItemBaseAbstract
$_className, $_oCache, $_settings, $db, $lasterror, $primaryKey, $properties, $secondDb, $table, $virgin
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0