query()->insertGetId($data); // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 返回结果 return $result; } /** * 编码转id * * @param string $code 编码 * */ public function codeToId($code){ return intval(str_ireplace('kldd','',$code)); } /** * id转编码 * * @param int $id 编码 * */ public function idToCode($id){ return 'kldd'. str_pad($id, 9, '0', STR_PAD_LEFT);; } /** * 获取订单产品数据 * * @param Array ID * @param String 指定字段 * */ public function getOne($id,$field='') { // 获取列表数据 $list = $this->getList(); // 获取数据 $one = isset($list[$id]) ? $list[$id] : []; // 返回值 return empty($field) ? $one : ( isset($one[$field]) ? $one[$field] : null); } }