Hi all,
I’m fairly new to the Yii framework, but i must say it’s working out pretty well for me so far
I do have a specific situation I’m having trouble with…
I’ve extended the CDataProvider class for the sole purpose of changing the way my fetchData() function behaves (everything else is pretty much similar to the definition of the CActiveDataProvider class). Inside fetchData(), instead of the usual:
return CActiveRecord::model($this->modelClass)->findAll($criteria);
…I’m calling a web service to get my data, in the following way:
$this->soapClient->getData($this->modelClass);
Here’s the code for getData inside my ServiceController class:
/**
* @param string the model
* @return array the data
* @soap
*/
public function getData($pModel)
{
$query = "SELECT * FROM {{" . $pModel . "}}";
$command=Yii::app()->db->createCommand($query);
return $command->query()->readAll();
}
So far so good, but the problem begins as soon as I’m trying to pass additional arguments for my query criteria (so I can get sorting, pagination enabled, etc). If I change my function to:
/**
* @param string the model
* @param CDbCriteria the criteria
* @return array the data
* @soap
*/
public function getData($pModel, $pCriteria)
{
$query = "SELECT * FROM {{" . $pModel . "}}";
if (!empty($pCriteria->order))
{
$query .= " ORDER BY " . $pCriteria->order . "";
}
$query .= " LIMIT " . $pCriteria->limit . " OFFSET " . $pCriteria->offset . "";
$command=Yii::app()->db->createCommand($query);
return $command->query()->readAll();
}
…I get the following error:
[b]Error 500
looks like we got no XML document[/b]
I realized that since I’m passing an object as one of my arguments, that it could be the reason for this, but I even tried passing my criteria parameters separately (like $pCriteria->order, $pCriteria->limit, $pCriteria->offset), and i still get the same error message. What could be causing this…
Thanks in advance