Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : Resource | ||
return | Resource | the static model class |
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Resource the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Resource::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Function to get Resource Object From Database **/ public static function getResourceObjectFromDatabase($model, $key) { $upload_files = array(); $resources = ObjectResource::model()->findAll(array('condition' => 'object_id = :obj and type = :type', 'order' => 'resource_id ASC', 'limit' => $model->total_number_resource > 0 ? $model->total_number_resource : 1, 'params' => array(':obj' => $model->object_id, ':type' => $key))); if ($resources & count($resources) > 0) { foreach ($resources as $res) { if ($find_resource = Resource::model()->findByPk($res->resource_id)) { $file = array(); $file['link'] = $find_resource->getFullPath(); $file['resid'] = $find_resource->resource_id; $file['type'] = $find_resource->resource_type; $upload_files[] = $file; } } } return $upload_files; }
echo $form->labelEx($model, 'name'); ?> <?php echo $form->textField($model, 'name', array('size' => 50, 'maxlength' => 50)); ?> <?php echo $form->error($model, 'name'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'resource_id'); ?> <?php echo $form->dropDownList($model, 'resource_id', CHtml::listData(Resource::model()->findAll(), 'id', 'name')); ?> <?php echo $form->error($model, 'resource_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'speed'); ?> <?php echo $form->textField($model, 'speed'); ?> <?php echo $form->error($model, 'speed');