Why not ?

Why the default Yii testdrive doesn’t uses $model as a property of the controller ?

instead of passing $model to render() then to renderPartial()…


class myController extends Controller {

public $model;


public function actionIndex() {

    $this->model=foo::model()->findAll();

    $this->render('index');

    }

}

the view:




<?php echo '<pre>';?>

<?php print_r($this->model);?>



Because it does not belong there. Also, even in your simple test case $model does not contain one model, but an array.

it is the default behavior in CakePHP :

http://book.cakephp.org/2.0/en/models.html

Sure Yii is better and faster but we also can copy/paste cool ideas…

Why not?

In my opinion… because Yii tries to be as elastic and open as possible. What about applications, when you don’t use models at all (look at the simpliest “Hanging man” demo application). Why to send empty model in such situation.

Which of course doesn’t limit you to do exactly as you wrote - declare own property in controller and use it in a view.