Revision #8 has been created by Kostas Apazidis (KonApaz) on Sep 25, 2013, 7:41:53 PM with the memo:
-
« previous (#7) next (#9) »
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,
));
```