예제 #1
0
 public function exportAction()
 {
     $people = Pidors::find();
     $export = utf8_decode(json_encode($people, JSON_UNESCAPED_UNICODE));
     $myfile = fopen($_SERVER['DOCUMENT_ROOT'] . $this->siteUrl . "/data/newfile.json", "w") or die("Unable to open file!");
     if (fwrite($myfile, $export)) {
         fclose($myfile);
     } else {
         'Депутаты сломали интернет!';
     }
 }
예제 #2
0
 public function createAction()
 {
     if ($this->request->isPost) {
         $input = $this->request->getPost();
         if (isset($input->id) && !empty($input->id)) {
             $pidor = new Pidors();
             foreach ($input as $key => $value) {
                 if ($key !== 'id') {
                     $pidor->{$key} = $value;
                 }
             }
             if (!$pidor->save()) {
                 $this->flash->error('Ошибка при сохранении');
             } else {
                 $this->flash->success('Депутат успешно добавлен');
             }
         } else {
             $this->flash->error('Неверный формат данных');
         }
     } else {
         $this->flash->error('Не переданы параметры');
     }
     $this->forward('people/list');
 }