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 CSqlDataProvider

CSqlDataProvider implements a data provider based on a plain SQL statement.

CSqlDataProvider provides data in terms of arrays, each representing a row of query result.

Like other data providers, CSqlDataProvider also supports sorting and pagination. It does so by modifying the given CSqlDataProvider::$sql statement with "ORDER BY" and "LIMIT" clauses. You may configure the sort and pagination properties to customize sorting and pagination behaviors.

CSqlDataProvider may be used in the following way:

$count=Yii::app()->db->createCommand('SELECT COUNT(*) FROM tbl_user')->queryScalar();
$sql='SELECT * FROM tbl_user';
$dataProvider=new CSqlDataProvider($sql, array(
    'totalItemCount'=>$count,
    '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 pagination feature, you must configure the totalItemCount property to be the total number of rows (without pagination). And 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 CSqlDataProvider
Package: system\web
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1.4
Located at x2engine/framework/web/CSqlDataProvider.php
Methods summary
public
# __construct( string|CDbCommand $sql, array $config = array() )

Constructor.

Constructor.

Parameters

$sql
string|CDbCommand
$sql the SQL statement to be used for fetching data rows. Since version 1.1.13 this can also be an instance of CDbCommand.
$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 is invoked when CDataProvider::getTotalItemCount() is invoked and totalItemCount is not set previously. The default implementation simply returns 0. You may override this method to return accurate total number of data items.

Calculates the total number of data items. This method is invoked when CDataProvider::getTotalItemCount() is invoked and totalItemCount is not set previously. The default implementation simply returns 0. You may override this method to return accurate total number of data items.

Returns

integer
the total number of data items.
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 CDbConnection $db
#

the database connection to be used in the queries. Defaults to null, meaning using Yii::app()->db.

the database connection to be used in the queries. Defaults to null, meaning using Yii::app()->db.

public string|CDbCommand $sql
#

the SQL statement to be used for fetching data rows. Since version 1.1.13 this can also be an instance of CDbCommand.

the SQL statement to be used for fetching data rows. Since version 1.1.13 this can also be an instance of CDbCommand.

public array $params array()
#

parameters (name=>value) to be bound to the SQL statement.

parameters (name=>value) to be bound to the SQL statement.

public string $keyField 'id'
#

the name of key field. Defaults to 'id'.

the name of key field. Defaults to 'id'.

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