/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ClassMeeting(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['ClassMeeting'])) { $model->attributes = $_POST['ClassMeeting']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } if (isset($_GET['class_id'])) { $model->class_id = $_GET['class_id']; $model->setNextMeeting(); } $this->render('create', array('model' => $model)); }
public function populate_meetings($count) { $model = $this; ///XXX hack! have to inject the count directly since it won't substitute! $c = Yii::app()->db->createCommand("select school_day from school_calendar where day_off < 1 and minimum < 1 and dayofweek(school_day) = :dayofweek and school_day >= :startdate and school_day <= :enddate limit {$count}"); $r = $c->queryAll(true, array('dayofweek' => $model->day_of_week, 'startdate' => $model->session->start_date, 'enddate' => $model->session->end_date)); foreach ($r as $i => $d) { $sc = new ClassMeeting(); $sc->meeting_date = $d['school_day']; $sc->class_id = $model->id; // TODO: trap errors here somehow $sc->save(); } }