order('gr_id ASC')->select(); return $list; } /** * 添加分组 * * @param array $data 数据 * @return bool */ public function add($data) { $db = new Db(); $result = $db->name('group')->insert($data); if ($result) { return true; } return false; } /** * 获取分组信息 * * @param int $id 分组ID * @return array|null */ public function getGroup($id) { $group = $this->find($id); if ($group) { return $group->toArray(); } return null; } /** * 更新分组信息 * * @param int $id 分组ID * @param array $data 数据 * @return bool */ public function updateGroup($id, $data) { $result = $this->where('id', $id)->update($data); if ($result !== false) { return true; } return false; } /** * 编辑分组 * * @param int $id 分组ID * @param array $data 分组数据 * @return bool */ public function edit($id, $data) { $result = $this->where('gr_id', $id)->update($data); return $result !== false; } /** * 删除分组 * * @param int $id 分组ID * @return bool */ public function deleteGroup($id) { $result = $this->where('id', $id)->delete(); if ($result > 0) { return true; } return false; } }