コード例 #1
0
ファイル: Principal.php プロジェクト: suryakencana/tekkadan
 /**
  * POST /principal
  *
  */
 public function s003()
 {
     $error;
     try {
         $req = App::request();
         if ($req->isPost()) {
             $post = $req->post();
             if (!empty($post["nama"])) {
                 $attributes = array("nama" => $post["nama"], "aktif" => isset($post["aktif"]) ? 1 : 0);
                 $table = Principal::table();
                 if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
                     $table->insert($attributes);
                 } else {
                     $where = "nama = '" . $post["gen_id"] . "'";
                     $table->update($attributes, $where);
                 }
             }
         }
     } catch (Exception $e) {
         $error = $e->getMessage();
         ZiUtil::unique_error($error);
         App::flash('error', $post["nama"] . ' ' . ZiUtil::unique_error($error));
         // App::flash('error', 'Terjadi kesalahan pada inputan anda.');
         App::redirect('principal.a001');
     }
     App::flash('info', 'Data Tersimpan.');
     App::redirect('principal.index');
 }