Playing with components

What do you think about this snippet of code?

(in first case, I have added User class as component)


return array(

    'components' => array(

        'users' => array(

            'class' => 'application.models.User'

        ),




                <?php foreach(Yii::app()->users->findAll() as $item)

                        echo $item->username; ?>


                <?php foreach(User::model()->findAll() as $item)

                        echo $item->username; ?>

I think it is wrong…

I believe in as minimum components as possible

What is this code supposed to do? Is it just for printing username of all users in your application? If so, you are loading pretty much useless data. Why to load whole user objects just to print one field of them?>