Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • 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
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • ArticleForum
  • cGenericDb
  • cGenericDbDriver
  • cGenericDbDriverMysql
  • cItemBaseAbstract
  • cItemCache
  • Item
  • ItemCollection
  • Overview
  • Package
  • Class
  • Todo
  • Download

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, cApiSearchTrackingCollection, cApiShortUrlCollection, cApiStatCollection, cApiSystemPropertyCollection, cApiTemplateCollection, cApiArticleLanguageCollection, cApiTemplateConfigurationCollection, cApiTypeCollection, cApiUploadCollection, cApiUploadMetaCollection, cApiUserCollection, cApiUserPasswordRequestCollection, cApiUserPropertyCollection, NewsletterCollection, NewsletterJobCollection, NewsletterLogCollection, cApiArticleSpecificationCollection, NewsletterRecipientCollection, NewsletterRecipientGroupCollection, NewsletterRecipientGroupMemberCollection, PifaFieldCollection, PifaFormCollection, PimPluginCollection, PimPluginRelationsCollection, WorkflowActions, WorkflowAllocations, WorkflowArtAllocations, cApiCategoryArticleCollection, WorkflowItems, Workflows, 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
The table to use as information source
$sPrimaryKey
The primary key to use

Throws

cInvalidArgumentException
If table name or primary key is not set

Overrides

cItemBaseAbstract::__construct()
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
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
Specifies the classname of item

Throws

cInvalidArgumentException

if the given class can not be instantiated

protected
# _initializeDriver( $bForceInit = false )

Initializes the driver to use with GenericDB.

Initializes the driver to use with GenericDB.

Parameters

$bForceInit

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

public
# setEncoding( string $sEncoding )

Sets the encoding.

Sets the encoding.

Parameters

$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
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
$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
$mRestriction
$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
$mRestriction
$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
$sField
$mRestriction
$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
$sField
$mRestriction
$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
$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
$sGroup2
$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
public
# addResultField( string $sField )

Adds a result field

Adds a result field

Parameters

$sField
public
# removeResultField( string $sField )

Removes existing result field

Removes existing result field

Parameters

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

Returns reverse join partner.

Returns reverse join partner.

Parameters

$sParentClass
$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
Specifies the where clause.
$sGroupBy
Specifies the group by clause.
$sOrderBy
Specifies the order by clause.
$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

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

$sFrom

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

$sWhere
Specifies the where clause.
$sGroupBy
Specifies the group by clause.
$sOrderBy
Specifies the order by clause.
$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
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( string $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
public array
# fetchTable( array $aFields = array(), array $aObjects = array() )

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.

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.

Parameters

$aFields
array with the fields to fetch
$aObjects

Returns

array
public array
# queryAndFetchStructured( array $aObjects )

Returns an array of arrays

Returns an array of arrays

Parameters

$aObjects
With the correct order of the objects

Returns

array
Result
protected array
# _recursiveStructuredFetch( array $aObjects, array $aResult )

Parameters

$aObjects
$aResult

Returns

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

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

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
Source Item instance to copy
$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
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
List of fields to get
$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
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
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
The field name
$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
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
Id of entries to delete (has to be called w/ an array!)

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
Name of the field to use for the key
$mFields
String or array

Returns

array
Resulting array
Methods inherited from cItemBaseAbstract
_getPropertiesCollectionInstance(), _getSecondDBInstance(), _resetItem(), 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. Contains all result items.

Storage of all result items. Contains all result items.

#
protected cGenericDbDriver $_driver

GenericDB driver object

GenericDB driver object

#
protected array $_collectionCache

List of instances of ItemCollection implementations

List of instances of ItemCollection implementations

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

Reverse join partners for this data object

Reverse join partners for this data object

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

Inner group conditions

Inner group conditions

# array()
protected array $_groupConditions

Group conditions

Group conditions

#
protected array $_resultFields

Result fields for the query

Result fields for the query

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

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.

# false
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.7 API documentation generated by ApiGen