query()->insert($data); // 失败返回0 if( !$result ) return ''; // 返回结果 return $data['id']; } /** * 添加数据 * */ public function edit($id,$data) { // 更新时间 $data['update_time'] = time(); // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 失败返回0 if( !$result ) return ''; // 返回结果 return $id; } /** * 添加数据 * */ public function getOne($id) { // 返回结果 $custom = $this->query()->where([['id','=',$id]])->first(['id','custom_uid','avatar','name','gender','status','type','corp_name','corp_full_name']); // 返回结果 if( !$custom ) return []; // 数据结构 return $custom->toArray(); } /** * 添加数据 * * @param int $id 客户ID * @param string $field 字段 */ public function getValue($id,$field) { // 返回结果 $result = $this->query()->where([['id','=',$id]])->value($field); // 数据结构 return $result; } }