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; } /** * 判断企业是否已报名 * 20220208 * wj */ public function checkiscompanysign($partyid, $companyid) { $where = [ 'party_id' => $partyid, 'company_id' => $companyid, ]; $info = $this->where($where)->find(); return !empty($info); } /** * 获取列表 join company * 20220209 * wj */ public function getListjoincompany($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false) { $useWhere = ['c.ispass' => 1]; if (isset($where['party_id'])) { $useWhere['pr.party_id'] = $where['party_id']; } $sqlObj = $this->alias('pr')->join('t_company c', 'c.id = pr.company_id')->where($useWhere); $order = "pr.id desc"; 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; } }