model() public static méthode

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Download
$className string active record class name.
Résultat Download the static model class
Exemple #1
0
 public function actionDownload($id)
 {
     $model = Download::model()->findByPk($id);
     if ($model == null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $comp = Company::model()->findByPk($model->company_id);
     $comp->select($model->company_id);
     $id = (int) $model->file_id;
     $model = Files::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $file = $model->getFullPath() . $model->id;
     return Yii::app()->getRequest()->sendFile($model->name, file_get_contents($file));
 }
 public function actionIndex()
 {
     $downloads = Download::model()->findAll();
     $this->render('index', array('downloads' => $downloads));
 }