Reputation: 4508
I have the following table
id name date_crated
1 first 2001
2 second 2002
3 third 2003
Now I'm getting data of the second row for example.
$secondRow= testTable::find()
->where(['id' => 2])
->one();
But now I want to print out everything including the name of cells. I mean I want to have access to everything.
So how can I print out 'id' , '2' , 'name', 'second' , 'date_created' , '2002'
?
Upvotes: 0
Views: 1675
Reputation: 25312
You should simply try something like this :
$data = [];
foreach ($secondRow->attributes as $name=>$value)
{
$data[] = $name;
$data[] = $value;
}
echo join(',', $data);
http://www.yiiframework.com/doc-2.0/yii-base-model.html#$attributes-detail
Upvotes: 1