Questions tagged [cactivedataprovider]

data provider for Yii PHP based on ActiveRecord

CActiveDataProvider is part of the Yii PHP framework. Excerpt from the v1.1 docs:

CActiveDataProvider provides data in terms of ActiveRecord (AR) objects which are of class modelClass. It uses the AR CActiveRecord::findAll method to retrieve the data from database. The criteria property can be used to specify various query options.

CActiveDataProvider may be used in the following way:

$dataProvider=new CActiveDataProvider('Post', array(
    'criteria'=>array(
        'condition'=>'status=1',
        'order'=>'create_time DESC',
        'with'=>array('author'),
    ),
    'countCriteria'=>array(
        'condition'=>'status=1',
        // 'order' and 'with' clauses have no meaning for the count query
    ),
    'pagination'=>array(
        'pageSize'=>20,
    ),
));
// $dataProvider->getData() will return a list of Post objects

Important Links

API reference

81 questions
0
votes
1 answer

Yii's CArrayDataProvider and new rows

Is there a way to show in a Grid that takes it data from CActiveDataProvider some new rows that are not actually yet into the database? here's my scenario.. I have to fill by X times (the quantity of a product in a bill) and provide to each row the…
PartySoft
  • 2,749
  • 7
  • 39
  • 55
0
votes
1 answer

How do I create a CGridView with custom columns from a CArrayDataProvider?

I have an array of models that looks something like this. The models are extensions of the base Yii model class (BazClass), so that's a little bit of a custom solution, but I don't see why it shouldn't work. $list = array ( 0 => FooClass#1 …
slhck
  • 36,575
  • 28
  • 148
  • 201
0
votes
2 answers

Yii - using MySQL AS clause field

Let's say I want to have a provide CActiveDataProvider for a CGridView. I need to put a SUM(invitesCount) AS invites into a Provider result. How to retrieve it? I guess I cannot just use $dataProvider->invites?
Joe
  • 2,551
  • 6
  • 38
  • 60
0
votes
1 answer

Why does not work CActiveDataProvider after change criteria

This code work fine: $criteria = new CDbCriteria; $criteria->compare('id', 1); $dataProvider = new CActiveDataProvider('User', array('criteria'=>$criteria)); foreach ($dataProvider->getData() as $value) var_dump($value->id); But when I change…
Nabi K.A.Z.
  • 9,887
  • 6
  • 59
  • 81
0
votes
0 answers

return some joined fields in CActiveDataProvider

My question is related to Yii framework. I have defined relations in a model class . How can I return some specific fields of the join in CActiveDataProvider ?
hd.
  • 17,596
  • 46
  • 115
  • 165
-1
votes
1 answer

Yii CSqlDataProvider with relations

I have an complex query with joins and conditions and I get data with CSqlDataProvider But I also need to join relational table records. Lets say, we have table A (products) and table B (product_modifications) I need to list products along with…
johnode
  • 720
  • 3
  • 12
  • 31
1 2 3 4 5
6