Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • ActionFormModelBase
  • CActiveDataProvider
  • CalendarEventFormModel
  • CallFormModel
  • CArrayDataProvider
  • CAssetManager
  • CBaseController
  • CBaseUrlRule
  • CCacheHttpSession
  • CClientScript
  • CController
  • CCookieCollection
  • CDataProvider
  • CDataProviderIterator
  • CDbHttpSession
  • CExtController
  • CFormModel
  • CHttpCookie
  • CHttpRequest
  • CHttpSession
  • CHttpSessionIterator
  • COutputEvent
  • CPagination
  • CreatePageFormModel
  • CSort
  • CSqlDataProvider
  • CTheme
  • CThemeManager
  • CUploadedFile
  • CUrlManager
  • CUrlRule
  • CWebApplication
  • CWebModule
  • CWidgetFactory
  • EditMobileFormsFormModel
  • EventCommentPublisherFormModel
  • EventFormModel
  • EventPublisherFormModel
  • FileSystemObjectDataProvider
  • MassActionFormModel
  • MobilePagination
  • NoteFormModel
  • NotificationsController
  • TimeFormModel
  • UploadLogoFormModel
  • X2FormModel
  • X2HttpRequest

Interfaces

  • IDataProvider
  • IWidgetFactory
  • Overview
  • Package
  • Class
  • Tree

Class CArrayDataProvider

CArrayDataProvider implements a data provider based on a raw data array.

The CArrayDataProvider::$rawData property contains all data that may be sorted and/or paginated. CArrayDataProvider will supply the data after sorting and/or pagination. You may configure the sort and pagination properties to customize sorting and pagination behaviors.

Elements in the raw data array may be either objects (e.g. model objects) or associative arrays (e.g. query results of DAO). Make sure to set the CArrayDataProvider::$keyField property to the name of the field that uniquely identifies a data record or false if you do not have such a field.

CArrayDataProvider may be used in the following way:

$rawData=Yii::app()->db->createCommand('SELECT * FROM tbl_user')->queryAll();
// or using: $rawData=User::model()->findAll();
$dataProvider=new CArrayDataProvider($rawData, array(
    'id'=>'user',
    'sort'=>array(
        'attributes'=>array(
             'id', 'username', 'email',
        ),
    ),
    'pagination'=>array(
        'pageSize'=>10,
    ),
));
// $dataProvider->getData() will return a list of arrays.

Note: if you want to use the sorting feature, you must configure sort property so that the provider knows which columns can be sorted.

CComponent
Extended by CDataProvider implements IDataProvider
Extended by CArrayDataProvider

Direct known subclasses

FileSystemObjectDataProvider
Package: system\web
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1.4
Located at x2engine/framework/web/CArrayDataProvider.php
Methods summary
public
# __construct( array $rawData, array $config = array() )

Constructor.

Constructor.

Parameters

$rawData
array
$rawData the data that is not paginated or sorted. The array elements must use zero-based integer keys.
$config
array
$config configuration (name=>value) to be applied as the initial property values of this class.
protected array
# fetchData( )

Fetches the data from the persistent data storage.

Fetches the data from the persistent data storage.

Returns

array
list of data items
protected array
# fetchKeys( )

Fetches the data item keys from the persistent data storage.

Fetches the data item keys from the persistent data storage.

Returns

array
list of data item keys.
protected integer
# calculateTotalItemCount( )

Calculates the total number of data items. This method simply returns the number of elements in CArrayDataProvider::$rawData.

Calculates the total number of data items. This method simply returns the number of elements in CArrayDataProvider::$rawData.

Returns

integer
the total number of data items.
protected
# sortData( array $directions )

Sorts the raw data according to the specified sorting instructions. After calling this method, CArrayDataProvider::$rawData will be modified.

Sorts the raw data according to the specified sorting instructions. After calling this method, CArrayDataProvider::$rawData will be modified.

Parameters

$directions
array
$directions the sorting directions (field name => whether it is descending sort)
protected mixed
# getSortingFieldValue( mixed $data, array $fields )

Get field for sorting, using dot like delimiter in query.

Get field for sorting, using dot like delimiter in query.

Parameters

$data
mixed
$data array or object
$fields
array
$fields sorting fields in $data

Returns

mixed
$data sorting field value
protected array
# getSortDirections( string $order )

Converts the "ORDER BY" clause into an array representing the sorting directions.

Converts the "ORDER BY" clause into an array representing the sorting directions.

Parameters

$order
string
$order the "ORDER BY" clause.

Returns

array
the sorting directions (field name => whether it is descending sort)
Methods inherited from CDataProvider
getData(), getId(), getItemCount(), getKeys(), getPagination(), getSort(), getTotalItemCount(), setData(), setId(), setKeys(), setPagination(), setSort(), setTotalItemCount()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public string $keyField 'id'
#

the name of the key field. This is a field that uniquely identifies a data record. In database this would be the primary key. Defaults to 'id'. If it's set to false, keys of CArrayDataProvider::$rawData array are used.

the name of the key field. This is a field that uniquely identifies a data record. In database this would be the primary key. Defaults to 'id'. If it's set to false, keys of CArrayDataProvider::$rawData array are used.

public array $rawData array()
#

the data that is not paginated or sorted. When pagination is enabled, this property usually contains more elements than data. The array elements must use zero-based integer keys.

the data that is not paginated or sorted. When pagination is enabled, this property usually contains more elements than data. The array elements must use zero-based integer keys.

public boolean $caseSensitiveSort true
#

controls how sorting works. True value means that case will be taken into account. False value will lead to the case insensitive sort. Default value is true.

controls how sorting works. True value means that case will be taken into account. False value will lead to the case insensitive sort. Default value is true.

Since

1.1.13
Magic properties inherited from CDataProvider
$data, $id, $itemCount, $keys, $pagination, $sort, $totalItemCount
API documentation generated by ApiGen 2.8.0