Changes
Title
unchanged
custom sql query results to CDetailView
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
custom, sql, query, CDetailView, CSqlDataProvider, CArrayDataProvider
Content
changed
[...]
----------------------------------------------------------
I show you now how to make the similar task using other Providers
**With CSqlDataProvider**
```php
$sqlProvider = new CSqlDataProvider('select * from your_table');
$sqlProvider = $sqlProvider->getData();
$sqlData = $sqlProvider[0];
$this->widget('zii.widgets.CDetailView', array(
'data' => $sqlData,
));
```
**With CArrayDataProvider**
```php
$connection = Yii::app()->db;
$command = $connection->createCommand('select * from your_table');
$row = $command->queryRow();
$sqlData = new CArrayDataProvider(array($row));
$sqlData = $sqlData->getData();
$sqlData = $sqlData[0];
$this->widget('zii.widgets.CDetailView', array(
'data' => $sqlData,
));
```