本文整理匯總了PHP中models\User::setName方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setName方法的具體用法?PHP User::setName怎麽用?PHP User::setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::setName方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: registerUser
function registerUser($postdata)
{
$regname = htmlentities($postdata['regname']);
$regpass = htmlentities($postdata['regpass']);
$regauth = htmlentities($postdata['regauth']);
$regpass = hash('sha256', $regpass);
$user = new User();
$user->setName($regname);
$user->setPassword($regpass);
$user->setAuthlevel($regauth);
$user->save();
}
示例2: setName
public function setName($name)
{
$this->_load();
return parent::setName($name);
}
示例3: validateOne
protected function validateOne()
{
setContentType("json");
$user = new User();
$given = array_keys($_POST);
$response["error"] = null;
if (count($given) == 1) {
if ($given[0] == "username") {
$user->setUsername($_POST["username"]);
} else {
if ($given[0] == "password") {
$user->setPassword($_POST["password"]);
} else {
if ($given[0] == "email") {
$user->setEmail($_POST["email"]);
} else {
if ($given[0] == "name") {
$user->setName($_POST["name"]);
} else {
if ($given[0] == "surname") {
$user->setSurname($_POST["surname"]);
} else {
setHTTPStatusCode("400");
return;
}
}
}
}
}
if (!$user->validate()) {
foreach ($user->getValidationFailures() as $failure) {
if ($given[0] == $failure->getPropertyPath()) {
$response["error"] = array("name" => $failure->getPropertyPath(), "message" => $failure->getMessage());
}
}
}
$this->viewString(json_encode($response));
} else {
setHTTPStatusCode("400");
}
}