listData empty array error


I have a problem, if i disable/delete all elements on my table and other view try to fill it with the Server::model()->findByAttributes(array(‘enabled’=>1)), ‘id’, ‘name’)

If i do:

$q = new CDbCriteria();

$q->addSearchCondition(‘enabled’, 1);

echo $form->dropDownList($model,‘id_server’, CHtml::listData(Server::model()->findAll($q), ‘id’, ‘name’),

This works… why?

Is there a way to implement it on model?

CActiveRecord::findByAttributes() returns a model instance or NULL when no matching records found. Use findAllByAttributes() to retrieve an array of model instances.