model = new \app\admin\model\third\Platform; } // 列表页 public function index() { if ($this->request->isAjax()) { list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = $this->model ->where($where) ->order($sort, $order) ->count(); $list = $this->model ->where($where) ->order($sort, $order) ->limit($offset, $limit) ->select(); $result = [ "total" => $total, "rows" => $list, ]; return json($result); } return $this->view->fetch(); } // 添加/编辑 public function add() { if ($this->request->isPost()) { $params = $this->request->post("row/a"); if ($params) { $params['createtime'] = time(); // 自动填充时间戳 $result = $this->model->save($params); if ($result) { $this->success(); } else { $this->error(__('Operation failed')); } } $this->error(__('Parameter %s can not be empty', '')); } return $this->view->fetch(); } // 删除 public function del($ids = "") { if ($ids) { $this->model->destroy($ids); $this->success(); } $this->error(__('Parameter %s can not be empty', 'ids')); } }