I have the following query
UserLogin::model()
-> with(array(
'Provider'=> array(
'select'=>'name'
)
))
-> findAll(array(
'select' => 'count(t.id) as count ',
'group'=>'provider_id',
'order'=>'provider_id'
));
and my view is
<?php foreach($providerCounts as $providerCount): ?>
<tr>
<td><?php echo $providerCount['Provider']['name']; ?></td>
<td><?php echo $providerCount['count']; ?></td>
</tr>
<?php endforeach; ?>
Here is the relation
'Provider'=>array(self::BELONGS_TO, 'Provider', 'provider_id'),
I am getting the error
Property “UserLogin.counts” is not defined.
The same query in a different model is working.
Now i have two question
- Why is the query not working
- How do i debug such errors in yii
You need specify public property count
For debug use xdebug for php + ext for FireFox for debugging php
Also use
yii-debug-toolbar(search in yii ext site)