Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function actionCreate()
- {
- $model=new Achievement;
- $modelTestSchedule = new TestSchedule;
- $modelTeachingMap = new TeachingMap;
- $modelTeacher = Teachers::getTeacherList();
- if(isset($_POST['Achievement']))
- {
- ...
- foreach($data['student_id'] as $key=>$value)
- {
- // $sql = {your sql, for example:}
- $sql .= "INSERT INTO achievement(student_id,result_value) VALUES('{$value}','{$data['result'][$key]}');";
- ++$i;
- }
- /* Transasction begin */
- $connection = Yii::app()->db;
- $transaction= $connection->beginTransaction();
- try
- {
- $connection->createCommand($sql)->execute();
- }
- catch(Exception $e)
- {
- $transaction->rollBack();
- throw new CHttpException(400,$e->getMessage());
- }
- }
- $this->render('create',array(
- 'model'=>$model,
- 'modelTestSchedule'=>$modelTestSchedule,
- 'modelTeachingMap'=>$modelTeachingMap,
- 'modelTeacher'=>$modelTeacher,
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement