I want to show all data from $result in my table but there's some error.
The notice is "Array to string conversion"
Here's the controller :
public function actionIndex()
{
$command = Yii::app()->db->createCommand('
Select username as user
From application_admin aa, application a
Where a.app_id = aa.app_id');
$reader = $command->query();
$dataUser = $reader->readAll();
$dataProvider = Application::model()->findAll();
foreach ($dataProvider as $data) {
$temp = array();
$name = $data->name;
$customer = $dataUser;
$category = $data->appCategory->name;
$temp['name'] = $name;
$temp['customer'] = $customer;
$temp['category'] = $category;
$result[] = $temp;
}
$this->render('index',array('result'=>$result));
}
and this is the View :
<?php
$i=1;
foreach ($result as $data){
?>
<tr class="center clickableRow">
<div>
<td><?php echo $i; ?></td>
<td><?php echo $data['name']; ?></td>
<td><?php echo $data['customer'];?></td> //error in this line
<td><?php echo $data['category'];?></td>
</div>
</tr >
<?php
$i++;
}
?>
Please give me some advice, thanks
var_dump($data['customer'])
and check the contents – kevinabelita 20 hours ago<?php echo $data['customer'];?>
to<?php print_r($data['customer']);?>
– asprin 20 hours ago