model() public static method

Returns the static model of the specified AR class.
public static model ( string $className = __CLASS__ ) : Download
$className string active record class name.
return Download the static model class
示例#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));
 }
示例#2
0
 public function actionIndex()
 {
     $downloads = Download::model()->findAll();
     $this->render('index', array('downloads' => $downloads));
 }