コード例 #1
0
ファイル: TableForm.php プロジェクト: mademingshiwo/todolist
 public function save()
 {
     if (is_numeric($this->id)) {
         $table = TbTable::findOne($this->id);
     } else {
         $table = new TbTable();
     }
     $table->fdName = $this->name;
     $table->fdText = $this->text;
     $table->fdSubText = $this->sub_text;
     $table->fdClass = $this->class;
     $table->fdDirection = $this->direction;
     $table->fdCondition = $this->condition;
     $table->fdLimit = 0 + $this->limit;
     $table->fdSummary = $this->summary;
     $table->fdSummaryGroup = $this->summary_group;
     $table->fdSummaryOrder = $this->summary_order;
     $table->fdSummaryLimit = $this->summary_limit;
     if (!$table->save()) {
         echo json_encode(['code' => -1, 'msg' => json_encode($table->errors, JSON_UNESCAPED_UNICODE)]);
         return false;
     }
     echo json_encode(['code' => 0, 'msg' => '请求操作成功', 'result' => ['id' => $table->id]]);
     return true;
 }