creation of model object in controller yii -
can 1 tell me how create model object inside constructor in yii. had written code belo
<?php class distributorscontroller extends controller { public $layout = '//layouts/column4'; public $defaultaction = null; public function __construct() { echo '<br>into constructor'; parent::__construct('distributors','distributors'); } public function actiondistributors() { $this->render("channelmask"); } }
?>
but displaying "into constructor" string , view not showing in browser.
you need call model controller.
create model, in controller, call :
distributor::model()->findall($criteria); //many models
or
distributor::model()->findbyid($id); // 1 model
Comments
Post a Comment