/** * 删除字段 * @param int $id 需要删除字段的id * @return array */ public function delete($id) { if (!isset($id) || !$this->existField($id)) { return resultReturn(false); } $Field = $this->getD(); $old = $Field->getById($id); $model = M('Model')->field('tbl_name')->getById($old['model_id']); $Field->startTrans(); $status = $Field->where("id={$old['id']}")->delete(); // 删除表中的字段 $dcs = $Field->dropColumn($model['tbl_name'], $old['name']); if (false === $status || false === $dcs) { $Field->addColumn($model['tbl_name'], $old['name'], $old['type'], $old['length'], $old['value'], $old['comment']); $Field->rollback(); return $this->resultReturn(false); } $Field->commit(); return $this->resultReturn(true); }
private function filterParam($userId, &$unick, $password, $rptpassword, $school, $email) { if (!isValidStringLength($userId, 3, 20)) { resultReturn(1002, array('msg' => '用户ID长度限制在3-20之间!')); } if (!isValidUserId($userId)) { resultReturn(1002, array('msg' => '用户ID只能包含数字和字母!')); } if (!isValidStringLength($unick, -1, 100)) { resultReturn(1002, array('msg' => '用户昵称长度不符合规范!')); } if (empty($unick)) { $unick = $userId; } if (strcmp($password, $rptpassword) != 0) { resultReturn(1002, array('msg' => '密码填写不一致!')); } if (!isValidStringLength($password, 6)) { resultReturn(1002, array('msg' => '密码长度至少6位!')); } if (!isValidStringLength($school, -1, 100)) { resultReturn(1002, array('msg' => '学校名称长度不符合规范!')); } if (!isValidStringLength($email, -1, 100)) { resultReturn(1002, array('msg' => '邮箱长度不符合规范!')); } else { if (!empty($email) && !isValidEmail($email)) { resultReturn(1002, array('msg' => '邮箱格式不符合规范!')); } } }