/** * 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($id) { $model = Floors::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
* Time: 15:46 */ class Floors { protected $floor = 0; protected $dir = array('(' => 'up', ')' => 'down'); public function up() { $this->floor++; } public function down() { $this->floor--; } public function read($input) { $chars = str_split($input); $basement = false; foreach ($chars as $i => $char) { $fn = $this->dir[$char]; $this->{$fn}(); if ($this->floor == -1 && !$basement) { $basement = true; echo "BASEMENT AT POSITION: " . ($i + 1); } } var_dump($this->floor); } } $f = new Floors(); $f->read(file_get_contents(__DIR__ . '/input/1'));
/** * @return \yii\db\ActiveQuery */ public function getFloors() { return $this->hasOne(Floors::className(), ['id' => 'floors_id']); }
?> <div class="row"> <?php echo $form->labelEx($model, 'tbl_room_name'); echo $form->textField($model, 'tbl_room_name', array('size' => 45, 'maxlength' => 45)); echo $form->error($model, 'tbl_room_name'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'tbl_floors_idtbl_floor'); ?> <?php $models = Floors::model()->findAll(array('order' => 'tbl_floor_name')); $list = CHtml::listData($models, 'idtbl_floor', 'tbl_floor_name'); echo CHtml::dropDownList('Rooms[tbl_floors_idtbl_floor]', $model->tblFloorsIdtblFloor, $list); echo $form->error($model, 'tbl_floors_idtbl_floor'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?>