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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -