本文整理汇总了PHP中UserDAO::insertUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO::insertUser方法的具体用法?PHP UserDAO::insertUser怎么用?PHP UserDAO::insertUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDAO
的用法示例。
在下文中一共展示了UserDAO::insertUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execSignup
function execSignup($username, $password, $confirmpw, $firstname, $lastname, $gender)
{
if ($username == "" || !isValidUsername($username)) {
return "Username is empty or invalid!";
}
if ($password == "" || !isValidPassword($password)) {
return "Password is empty or invalid!";
}
if ($confirmpw == "" || !isValidPassword($confirmpw)) {
return "Confirm Password is empty or invalid!";
}
if ($firstname == "" || !isValidName($firstname)) {
return "First Name is empty or invalid!";
}
if ($lastname == "" || !isValidName($lastname)) {
return "Last Name is empty or invalid!";
}
if ($gender == "" || !isValidGender($gender)) {
return "Gender is empty or invalid!";
}
$userDAO = new UserDAO();
//verify username exist
$result = $userDAO->getUserByUsername($username);
if ($result !== null) {
return "Username exists, please change to another one!";
}
//verify $password == $confirmpw
if ($password != $confirmpw) {
return "Password and Confirm Password must be same!";
}
$roleDAO = new RoleDAO();
$role = $roleDAO->getRoleByID(3);
//normal user
$departmentDAO = new DepartmentDAO();
$depart = $departmentDAO->getDepartmentByID(1);
//root department
$encryptPW = encryptPassword($password);
$photoURL = "photo/default.png";
$user = new User($role, $depart, $username, $encryptPW, $firstname, $lastname, $gender, $photoURL);
if ($userDAO->insertUser($user) === true) {
return true;
} else {
return "Insert user into table error, please contact administrator!";
}
}
示例2: elseif
} else {
JsonResponse::sendResponse(404, "Invalid Spire API Request");
}
} elseif (isset($_GET['user']) && (User::isAdmin($_SESSION['user_type']) || $_SESSION['user'] == $_GET['user'])) {
if ($_SERVER['REQUEST_METHOD'] === "GET") {
$user_id = $_GET['user'];
$fnHash = UserDAO::getUsers($user_id);
$logger->writeLog("fnHash['ok'] = " . $fnHash['ok']);
if ($fnHash['ok']) {
JsonResponse::sendResponse(200, $fnHash['result']);
} else {
JsonResponse::sendResponse(400, $fnHash['reason']);
}
} elseif ($_SERVER['REQUEST_METHOD'] === "POST" && User::isAdmin($_SESSION['user_type'])) {
$logger->writeLog("Inserting: " . $request_data->email);
$fnHash = UserDAO::insertUser($request_data->email, $request_data->password, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
if ($fnHash['ok']) {
JsonResponse::sendResponse(200, $fnHash['reason']);
} else {
JsonResponse::sendResponse(400, $fnHash['reason']);
}
} elseif ($_SERVER['REQUEST_METHOD'] === "PUT" && User::isAdmin($_SESSION['user_type'])) {
$logger->writeLog("Updating: " . $request_data->id);
$fnHash = UserDAO::updateUser($request_data->id, $request_data->email, $request_data->first_name, $request_data->last_name, $request_data->phone_nbr, $request_data->facebook_id, $request_data->twitter_id, $request_data->google_id, $request_data->tumblr_id, $request_data->instagram_id, $request_data->img_url, $request_data->img_file_path);
if ($fnHash['ok']) {
JsonResponse::sendResponse(200, $fnHash['reason']);
} else {
JsonResponse::sendResponse(400, $fnHash['reason']);
}
} elseif ($_SERVER['REQUEST_METHOD'] === "DELETE" && User::isAdmin($_SESSION['user_type'])) {
$user_id = $_GET['user'];