public static function getLessonCont($id){ $summary=[]; $cont = LectureElement::model()->findAll("id_lecture=:id and id_type=:type", array(':type'=>'8', ':id'=>$id)); $i=0; foreach($cont as $type){ $summary[$i] =$type->html_block; $i++; } return $summary; }
public function swapBlocks($idLecture, $first, $second) { //find blocks id's for first and second elements $firstId = LectureElement::model()->findByAttributes(array('id_lecture' => $idLecture, 'block_order' => $first))->id_block; $secondId = LectureElement::model()->findByAttributes(array('id_lecture' => $idLecture, 'block_order' => $second))->id_block; //swap blocks - rewrite block order in DB LectureElement::model()->updateByPk($secondId, array('block_order' => $first)); LectureElement::model()->updateByPk($firstId, array('block_order' => $second)); }