Hi guys,
I run into some problems… I’m using the queryCriteria branch in my project.
I have a client class
class Client extends EActiveResource
{
public $id;
public $numFound=0;
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function rest()
{
return CMap::mergeArray(
parent::rest(),
array(
'resource'=>'client',
'idProperty'=>'id',
)
);
}
/* Let's define some properties and their datatypes*/
public function properties()
{
return array(
'name'=>array('type'=>'string'),
'birthday'=>array('type'=>'string'),
'gender'=>array('type'=>'string'),
'language'=>array('type'=>'string'),
);
}
/* Define rules as usual */
public function rules()
{
return array(
array('name,gender,birthday','safe'),
);
}
/* Add some custom labels for forms etc. */
public function attributeLabels()
{
return array(
'name'=>'First name',
'birthday'=>'Birthday',
'gender'=>'Sex',
'id'=>'ID',
);
}
public function populateRecord($attributes,$callAfterFind=true)
{
//code to populate record
}
public function populateRecords($data,$callAfterFind=true,$index=null)
{
//extract params foreach populate record and add to class list
}
}
in my view file (just to test) I create an EACtiverResourceCriteria which I use to create an EActiveResourceDataProvider which I can use to fill u my gridview (bootstrap gridview -> but I’ve tried the CGridView as well with the same result…)
$criteria=new EActiveResourceQueryCriteria(array(
'condition'=>'name=:username',
'params'=>array(':username'=>'*')
));
$clients=Client::model()->findAll($criteria); //this is working
$dataProvider=new EActiveResourceDataProvider('Client',array('criteria'=>$criteria));
$this->widget('bootstrap.widgets.TbGridView',
array(
'type'=>'striped bordered condensed',
'dataProvider'=>$dataProvider,
//'filter' => $model,
'columns'=>array(
array('name'=>'name', 'header'=>'Name'),
array('name'=>'gender', 'header'=>'Sex'),
array('name'=>'language', 'header'=>'Language'),
array('name'=>'birthday', 'header'=>'Birthday'),
),
));
the first error was.
Client and its behaviors do not have a method or closure named "tableName".
So I’ve added the following to my Client class
public function tableName()
{
return 'Client';
}
Then I received…
Client and its behaviors do not have a method or closure named "getDbConnection".
So I’ve implmented a getDbConnection method that returns null… But then the system tries to get the schema from the null object and the errors keep on comming.
Can someone help me ?
How can I implement the dataprovider for EActiveResource ?
thanks