formatData($data); if (empty($data)) { return false; } $id = $this->insertGetId($data); return empty($id) ? false : $id; } /** * 校验入库数据 * 20220119 */ private function formatData($data) { $useData = []; $fields = $this->getTableFields(); foreach ($data as $key => $value) { if (in_array($key, $fields)) { $useData[$key] = $value; } } return $useData; } public function getInfo($where, $field = "*", $row = true) { $info = $this->field($field)->where($where); if ($row) { $info = $info->find(); } else { $info = $info->select(); } return empty($info) ? false : $info; } public function updateinfo($where, $updateData) { $row = $this->where($where)->update($updateData); return empty($row) ? false : $row; } public function deleteinfo($where) { $row = $this->where($where)->delete(); return empty($row) ? false : $row; } public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false) { $sqlObj = $this->where($where); if ("count" != $field) { $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size); if ($row) { $data = $sqlObj->find(); } else { $data = $sqlObj->select(); } } else { $data = $sqlObj = $sqlObj->count(); } return $data; } /** * 根据id获取信息 * wj * 20220118 */ public function getinfobyid($id) { $where = ['id' => $id]; $info = $this->where($where)->find(); return $info; } /** * 根据openid获取信息 * wj * 20220118 */ public function getinfobyopenid($openid) { $where = ['openid' => $openid]; $info = $this->where($where)->find(); return $info; } /** * 根据openid获取信息 * wj * 20220118 */ public function getfieldbyopenid($openid, $field = "") { if (empty($field)) { $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company", "nation", "origin", "address"]; } $where = ['openid' => $openid]; $info = $this->field($field)->where($where)->find(); return $info; } /** * 根据id获取信息 * wj * 20220118 */ public function getfieldbyid($id, $field = "") { if (empty($field)) { $field = ["id", "user_name", "telno", "gender", "age", "email", "is_active", "is_company", "nation", "origin", "address"]; } $where = ['id' => $id]; $info = $this->field($field)->where($where)->find(); return $info; } /** * 根据openid获取信息 * wj * 20220118 */ public function getinfobysfzid($sfzid) { $where = ['sfzid' => $sfzid]; $info = $this->where($where)->find(); return $info; } /** * 根据telno获取信息 * wj * 20220118 */ public function getinfobytelno($telno) { $where = ['telno' => $telno]; $info = $this->where($where)->find(); return $info; } /** * 根据openid获取修改unionid * wj * 20220118 */ public function updateunionidbyopenid($openid, $unionid) { $where = ['openid' => $openid]; $updateData = ['unionid' => $unionid]; $row = $this->where($where)->update($updateData); return $row; } /** * 根据openid获取修改iscompany * wj * 20220118 */ public function updateiscompanybyopenid($openid, $iscompany = 1) { $where = ['openid' => $openid]; $updateData = ['is_company' => $iscompany]; $row = $this->where($where)->update($updateData); return $row; } /** * 根据id修改数据 * wj * 20220118 */ public function updatebyid($id, $updateData) { $where = ['id' => $id]; $updateData = $this->formatData($updateData); if (empty($updateData)) { return false; } $row = $this->where($where)->update($updateData); return $row; } }