/** * 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 the ID of the model to be loaded */ public static function loadModelByPid($type, $id) { if ($type == 'Employees') { $model = EmployeeSchedule::model()->findAllByAttributes(array('pid' => $id)); } elseif ($type == 'Hardware') { $model = HardwareSchedule::model()->findAllByAttributes(array('pid' => $id)); } elseif ($type == 'Facilities') { $model = FacilitySchedule::model()->findAllByAttributes(array('pid' => $id)); } elseif ($type == 'CustomResources') { $model = CustomResources::model()->findAllByAttributes(array('pid' => $id)); } return $model; }
/** * 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 the ID of the model to be loaded */ public function loadModel($type, $id) { if ($type == 'Employees') { $model = Employees::model()->findByPk($id); } elseif ($type == 'Hardware') { $model = Hardware::model()->findByPk($id); } elseif ($type == 'Facilities') { $model = Facilities::model()->findByPk($id); } elseif ($type == 'CustomResources') { $model = CustomResources::model()->findByPk($id); } if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }