Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : PreviousOperation | ||
Résultat | PreviousOperation | the static model class |
public function actionGetPreviousOperation() { if (!($po = PreviousOperation::model()->findByPk(@$_GET['operation_id']))) { throw new Exception("Previous operation not found: " . @$_GET['operation_id']); } $date = explode('-', $po->date); echo json_encode(array('operation' => $po->operation, 'side_id' => $po->side_id, 'fuzzy_year' => $date[0], 'fuzzy_month' => preg_replace('/^0/', '', $date[1]), 'fuzzy_day' => preg_replace('/^0/', '', $date[2]))); }
public function addPreviousOperation($operation, $side_id, $date) { if (!($pa = PreviousOperation::model()->find('patient_id=? and operation=? and date=?', array($this->id, $operation, $date)))) { $pa = new PreviousOperation(); $pa->patient_id = $this->id; $pa->operation = $operation; $pa->date = $date; } $pa->side_id = $side_id ? $side_id : null; if (!$pa->save()) { throw new Exception("Unable to save previous operation: " . print_r($pa->getErrors(), true)); } }