Class Varien_Data_Collection_Db

Description

Base items collection class

Located in /Data/Collection/Db.php (line 35)

Varien_Data_Collection
   |
   --Varien_Data_Collection_Db
Variable Summary
array $_bindParams
array $_cacheConf
Zend_Db_Adapter_Abstract $_conn
array $_data
Zend_Db_Statement_Pdo $_fetchStmt
string $_idFieldName
array $_map
Zend_Db_Select $_select
Method Summary
Varien_Data_Collection_Db __construct ([ $conn = null])
Varien_Data_Collection_Db addBindParam (string $name, mixed $value)
Mage_Eav_Model_Entity_Collection_Abstract addFieldToFilter (string $field, [null|string|array $condition = null])
Varien_Data_Collection_Db addFilterToMap (string $filter, string $alias, [string $group = 'fields'])
Varien_Data_Collection_Db addOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
void distinct (bool $flag)
void fetchItem ()
Zend_Db_Adapter_Abstract getConnection ()
array getData ()
string getIdFieldName ()
string getSelectSql ([bool $stringMode = false])
int getSize ()
Varien_Data_Collection_Db initCache ($object $object, string $idPrefix, array $tags)
Varien_Data_Collection_Db load ([ $printQuery = false], [ $logQuery = false])
void loadData ([ $printQuery = false], [ $logQuery = false])
Varien_Data_Collection_Db printLogQuery ([boolean $printQuery = false], [boolean $logQuery = false], [ $sql = null])
Varien_Data_Collection_Db setConnection (Zend_Db_Adapter_Abstract $conn)
Varien_Data_Collection_Db setOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
Varien_Data_Collection_Db unshiftOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
void _afterLoad ()
bool _canUseCache ()
array _fetchAll (Zend_Db_Select $select)
Zend_Cache_Core _getCacheInstance ()
array _getCacheTags ()
void _getConditionFieldName ( $fieldName)
string _getConditionSql (string|array $fieldName, integer|string|array $condition)
mixed _getItemId ( $item)
string _getMappedField (string $field)
void _getMapper ()
string _getSelectCacheId (Zend_Db_Select $select)
string _loadCache (Zend_Db_Select $select)
unknown_type _saveCache (array $data, Zend_Db_Select $select)
array _toOptionHashOptimized ([string $valueField = 'id'], [string $labelField = 'name'])
Variables
array $_bindParams = array() (line 72)

List of binded variables for select

  • access: protected
array $_cacheConf = null (line 56)

Cache configuration array

  • access: protected
Zend_Db_Adapter_Abstract $_conn (line 42)

DB connection

  • access: protected
array $_data = null (line 80)

All collection data array Used for getData method

  • access: protected
Zend_Db_Statement_Pdo $_fetchStmt = null (line 94)

Database's statement for fetch item one by one

  • access: protected
string $_idFieldName (line 65)

Identifier fild name for collection items

Can be used by collections with items without defined

  • access: protected
array $_map = null (line 87)

Fields map for corellation names & real selected fields

  • access: protected
Zend_Db_Select $_select (line 49)

Select oblect

  • access: protected

Inherited Variables

Inherited from Varien_Data_Collection

Varien_Data_Collection::$_cacheKey
Varien_Data_Collection::$_cacheLifetime
Varien_Data_Collection::$_cacheTags
Varien_Data_Collection::$_curPage
Varien_Data_Collection::$_filters
Varien_Data_Collection::$_flags
Varien_Data_Collection::$_isCollectionLoaded
Varien_Data_Collection::$_isFiltersRendered
Varien_Data_Collection::$_itemObjectClass
Varien_Data_Collection::$_items
Varien_Data_Collection::$_orders
Varien_Data_Collection::$_pageSize
Varien_Data_Collection::$_totalRecords
Methods
Constructor __construct (line 96)
  • access: public
Varien_Data_Collection_Db __construct ([ $conn = null])
  • $conn

Redefinition of:
Varien_Data_Collection::__construct()
addBindParam (line 111)

Add variable to bind list

  • access: public
Varien_Data_Collection_Db addBindParam (string $name, mixed $value)
  • string $name
  • mixed $value
addFieldToFilter (line 373)

Add field filter to collection

  • see: self::_getConditionSql for $condition
  • access: public
Mage_Eav_Model_Entity_Collection_Abstract addFieldToFilter (string $field, [null|string|array $condition = null])
  • string $field
  • null|string|array $condition
addFilterToMap (line 878)

Add filter to Map

  • access: public
Varien_Data_Collection_Db addFilterToMap (string $filter, string $alias, [string $group = 'fields'])
  • string $filter
  • string $alias
  • string $group: default 'fields'
addOrder (line 275)

self::setOrder() alias

  • access: public
Varien_Data_Collection_Db addOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
  • string $field
  • string $direction
distinct (line 582)

Set select distinct

  • access: public
void distinct (bool $flag)
  • bool $flag

Redefinition of:
Varien_Data_Collection::distinct()
Set select distinct
fetchItem (line 642)

Returns a collection item that corresponds to the fetched row and moves the internal data pointer ahead

return Varien_Object|bool

  • access: public
void fetchItem ()
getConnection (line 203)

Retrieve connection object

  • access: public
Zend_Db_Adapter_Abstract getConnection ()
getData (line 690)

Get all data array for collection

  • access: public
array getData ()
getIdFieldName (line 152)

Id field name getter

  • access: public
string getIdFieldName ()
getSelect (line 193)

Get Zend_Db_Select instance

  • access: public
Varien_Db_Select getSelect ()
getSelectCountSql (line 227)

Get SQL for get record count

  • access: public
Varien_Db_Select getSelectCountSql ()
getSelectSql (line 248)

Get sql select string or object

  • return: || Zend_Db_Select
string getSelectSql ([bool $stringMode = false])
  • bool $stringMode
getSize (line 213)

Get collection size

  • access: public
int getSize ()

Redefinition of:
Varien_Data_Collection::getSize()
Retrieve collection all items count
initCache (line 125)

Initialize collection cache

  • access: public
Varien_Data_Collection_Db initCache ($object $object, string $idPrefix, array $tags)
  • string $idPrefix
  • array $tags
  • $object $object
load (line 603)

Load data

  • access: public
Varien_Data_Collection_Db load ([ $printQuery = false], [ $logQuery = false])
  • $printQuery
  • $logQuery

Redefinition of:
Varien_Data_Collection::load()
Load data
loadData (line 728)
  • access: public
void loadData ([ $printQuery = false], [ $logQuery = false])
  • $printQuery
  • $logQuery

Redefinition of:
Varien_Data_Collection::loadData()
Load data
printLogQuery (line 740)

Print and/or log query

  • access: public
Varien_Data_Collection_Db printLogQuery ([boolean $printQuery = false], [boolean $logQuery = false], [ $sql = null])
  • boolean $printQuery
  • boolean $logQuery
  • $sql
resetData (line 717)

Reset loaded for collection data array

  • access: public
setConnection (line 177)

Set database connection adapter

  • access: public
Varien_Data_Collection_Db setConnection (Zend_Db_Adapter_Abstract $conn)
  • Zend_Db_Adapter_Abstract $conn
setOrder (line 263)

Add select order

  • access: public
Varien_Data_Collection_Db setOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
  • string $field
  • string $direction

Redefinition of:
Varien_Data_Collection::setOrder()
Set select order
unshiftOrder (line 287)

Add select order to the beginning

  • access: public
Varien_Data_Collection_Db unshiftOrder (string $field, [string $direction = self::SORT_ORDER_DESC])
  • string $field
  • string $direction
_afterLoad (line 723)
  • access: protected
void _afterLoad ()
_afterLoadData (line 707)

Proces loaded collection data

  • access: protected
Varien_Data_Collection_Db _afterLoadData ()
_beforeLoad (line 593)

Before load action

  • access: protected
Varien_Data_Collection_Db _beforeLoad ()
_canUseCache (line 823)

Check if cache can be used for collection data

  • access: protected
bool _canUseCache ()
_fetchAll (line 772)

Fetch collection data

  • access: protected
array _fetchAll (Zend_Db_Select $select)
  • Zend_Db_Select $select
_getCacheInstance (line 848)

Retrieve cache instance

  • access: protected
Zend_Cache_Core _getCacheInstance ()
_getCacheTags (line 861)

Get cache tags list

  • access: protected
array _getCacheTags ()
_getConditionFieldName (line 540)
  • access: protected
void _getConditionFieldName ( $fieldName)
  • $fieldName
_getConditionSql (line 428)

Build SQL statement for condition

If $condition integer or string - exact value will be filtered

If $condition is array is - one of the following structures is expected:

  • array("from"=>$fromValue, "to"=>$toValue)
  • array("like"=>$likeValue)
  • array("neq"=>$notEqualValue)
  • array("in"=>array($inValues))
  • array("nin"=>array($notInValues))
If non matched - sequential array is expected and OR conditions will be built using above mentioned structure

  • access: protected
string _getConditionSql (string|array $fieldName, integer|string|array $condition)
  • string|array $fieldName
  • integer|string|array $condition
_getItemId (line 163)

Get collection item identifier

  • access: protected
mixed _getItemId ( $item)

Redefinition of:
Varien_Data_Collection::_getItemId()
Retrieve item id
_getMappedField (line 386)

Try to get mapped field name for filter to collection

  • access: protected
string _getMappedField (string $field)
  • string $field
_getMapper (line 399)
  • access: protected
void _getMapper ()
_getSelectCacheId (line 834)

Get cache identifier base on select

  • access: protected
string _getSelectCacheId (Zend_Db_Select $select)
  • Zend_Db_Select $select
_loadCache (line 794)

Load cached data for select

  • return: | false
  • access: protected
string _loadCache (Zend_Db_Select $select)
  • Zend_Db_Select $select
_renderFilters (line 325)

Render sql select conditions

  • access: protected
Varien_Data_Collection_Db _renderFilters ()

Redefinition of:
Varien_Data_Collection::_renderFilters()
Render sql select conditions
_renderFiltersBefore (line 361)

Hook for operations before rendering filters

  • access: protected
void _renderFiltersBefore ()
_renderLimit (line 568)

Render sql select limit

  • access: protected
Varien_Data_Collection_Db _renderLimit ()

Redefinition of:
Varien_Data_Collection::_renderLimit()
Render sql select limit
_renderOrders (line 550)

Render sql select orders

  • access: protected
Varien_Data_Collection_Db _renderOrders ()

Redefinition of:
Varien_Data_Collection::_renderOrders()
Render sql select orders
_reset (line 756)

Reset collection

  • access: protected
_saveCache (line 811)

Save collection data to cache

  • access: protected
unknown_type _saveCache (array $data, Zend_Db_Select $select)
  • array $data
  • Zend_Db_Select $select
_setIdFieldName (line 141)

Specify collection objects id field name

  • access: protected
Varien_Data_Collection_Db _setIdFieldName (string $fieldName)
  • string $fieldName
_toOptionHashOptimized (line 676)

Convert items array to hash for select options unsing fetchItem method

The difference between _toOptionHash() and this one is that this method fetch items one by one and does not load all collection items at once return items hash array($value => $label)

array _toOptionHashOptimized ([string $valueField = 'id'], [string $labelField = 'name'])
  • string $valueField
  • string $labelField

Inherited Methods

Inherited From Varien_Data_Collection

Varien_Data_Collection::__construct()
Varien_Data_Collection::addFilter()
Varien_Data_Collection::addItem()
Varien_Data_Collection::clear()
Varien_Data_Collection::count()
Varien_Data_Collection::distinct()
Varien_Data_Collection::each()
Varien_Data_Collection::getAllIds()
Varien_Data_Collection::getCacheKey()
Varien_Data_Collection::getCacheLifetime()
Varien_Data_Collection::getCacheTags()
Varien_Data_Collection::getColumnValues()
Varien_Data_Collection::getCurPage()
Varien_Data_Collection::getFilter()
Varien_Data_Collection::getFirstItem()
Varien_Data_Collection::getFlag()
Varien_Data_Collection::getItemByColumnValue()
Varien_Data_Collection::getItemById()
Varien_Data_Collection::getItems()
Varien_Data_Collection::getItemsByColumnValue()
Varien_Data_Collection::getIterator()
Varien_Data_Collection::getLastItem()
Varien_Data_Collection::getLastPageNumber()
Varien_Data_Collection::getNewEmptyItem()
Varien_Data_Collection::getPageSize()
Varien_Data_Collection::getSize()
Varien_Data_Collection::hasFlag()
Varien_Data_Collection::isLoaded()
Varien_Data_Collection::load()
Varien_Data_Collection::loadData()
Varien_Data_Collection::removeItemByKey()
Varien_Data_Collection::setCacheKey()
Varien_Data_Collection::setCacheTags()
Varien_Data_Collection::setCurPage()
Varien_Data_Collection::setDataToAll()
Varien_Data_Collection::setFlag()
Varien_Data_Collection::setItemObjectClass()
Varien_Data_Collection::setOrder()
Varien_Data_Collection::setPageSize()
Varien_Data_Collection::toArray()
Varien_Data_Collection::toOptionArray()
Varien_Data_Collection::toOptionHash()
Varien_Data_Collection::toXml()
Varien_Data_Collection::walk()
Varien_Data_Collection::_getItemId()
Varien_Data_Collection::_renderFilters()
Varien_Data_Collection::_renderLimit()
Varien_Data_Collection::_renderOrders()
Varien_Data_Collection::_setIsLoaded()
Varien_Data_Collection::_toOptionArray()
Varien_Data_Collection::_toOptionHash()
Class Constants

Documentation generated on Fri, 11 Feb 2011 16:53:16 +0200 by phpDocumentor 1.4.3