本文整理汇总了PHP中UserModel::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::create方法的具体用法?PHP UserModel::create怎么用?PHP UserModel::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$faker = Faker\Factory::create();
for ($i = 0; $i < 50; $i++) {
UserModel::create(['name' => $faker->firstName . " " . $faker->lastName, 'email' => $faker->safeEmail, 'password' => 'password', 'phone' => '']);
}
}
示例2: register
public function register($user_name, $password, $first_name, $last_name)
{
if (!is_null(UserModel::findFirst(array('user_name' => $user_name)))) {
return UserHandler::ERROR_EXISTS;
}
$user = UserModel::create(array('user_name' => $user_name, 'password' => Utilities::hash($password, static::$salt), 'first_name' => $first_name, 'last_name' => $last_name, 'lang' => I18N::lang()));
$this->_login($user);
return $user;
}
示例3: run
public function run()
{
$faker = Faker\Factory::create();
$access = [1 => 'staff', 2 => 'associate'];
for ($i = 0; $i < 5; $i++) {
$user = UserModel::create(['name' => $faker->firstName . " " . $faker->lastName, 'email' => $faker->safeEmail, 'password' => 'password', 'phone' => '']);
$staff = StaffModel::create(['user_id' => $user->id, 'title' => '', 'access' => $faker->numberBetween(1, 2), 'instruction' => (int) true]);
Artisan::call('scheduler:services', ['staff' => $staff->id, 'level' => $access[$staff->access]]);
}
}
示例4: create
function create()
{
$usr = new UserDAO();
$usr->setName($_POST['name']);
$usr->setAge($_POST['age']);
$model = new UserModel();
$res = $model->create($usr);
if ($res == 1) {
header("Location: " . SITE_URL . "/user/addnew/?e=1");
}
}
示例5: registerAction
public function registerAction()
{
/**
* ToDo: Registration success messages
*/
if (isset($_POST["registerForm"]) && !empty($_POST["registerForm"])) {
$filteredUserInfo = array();
foreach ($_POST["registerForm"] as $key => $value) {
$filteredUserInfo[$key] = filterGetValue($value);
}
$model = new UserModel();
$model->create($filteredUserInfo);
}
$this->render("register", "user");
}
示例6: run
public function run()
{
$users = array(array('name' => "Brian Jacobs", 'email' => "bjacobs1@rochester.rr.com", 'password' => "nikegolf", 'phone' => '585-415-9323', 'address' => '284 Chambers St. Spencerport, NY'), array('name' => "David VanScott", 'email' => "david.vanscott@gmail.com", 'password' => "alpha312", 'phone' => '585-576-8260', 'address' => '2145 East Ave. Apt H Rochester, NY 14610'));
foreach ($users as $user) {
UserModel::create($user);
}
$staff = array(array('user_id' => 1, 'access' => 2, 'title' => "Senior Instructor", 'instruction' => (int) true), array('user_id' => 2, 'access' => 3, 'title' => "Web Developer"));
foreach ($staff as $s) {
$item = StaffModel::create($s);
// Create general availability
for ($d = 0; $d <= 6; $d++) {
StaffScheduleModel::create(array('staff_id' => $item->id, 'day' => $d, 'availability' => '9:00-17:00'));
}
}
}
示例7: populateTables
protected function populateTables()
{
$users = [['name' => "Brian Jacobs", 'email' => "bjacobs1@rochester.rr.com", 'password' => "nikegolf", 'phone' => '585-415-9323', 'address' => '284 Chambers St. Spencerport, NY'], ['name' => "David VanScott", 'email' => "david.vanscott@gmail.com", 'password' => "alpha312", 'phone' => '585-576-8260', 'address' => '2145 East Ave. Apt H Rochester, NY 14610']];
foreach ($users as $user) {
UserModel::create($user);
}
$staff = [['user_id' => 1, 'access' => 3, 'title' => "Director of Instruction", 'instruction' => (int) true], ['user_id' => 2, 'access' => 4, 'title' => "Web Developer"]];
foreach ($staff as $s) {
$item = StaffModel::create($s);
// Create general availability
for ($d = 0; $d <= 6; $d++) {
StaffScheduleModel::create(['staff_id' => $item->id, 'day' => $d, 'availability' => '9:00-17:00']);
}
}
}
示例8: createAction
public function createAction()
{
CApp::setTitle(CApp::getAppName() . " | " . CApp::getTranslate('createUser'));
if ($_SESSION["userRole"] == CApp::settings("USER_ROLES")->ADMIN) {
$model = new UserModel();
if (!empty($_POST["user"])) {
foreach ($_POST["user"] as $key => $value) {
$arrPost[$key] = filterGetValue($value);
}
$model->create($arrPost);
}
$this->render("create", "user");
} else {
CApp::redirect("/");
}
}
示例9: run
public function run()
{
// Start a customers array
$customers = array();
if (App::environment() != 'production') {
$faker = Faker\Factory::create();
}
// Open the file for reading
$handle = fopen(App::make('path.base') . '/CustomerList.csv', 'r');
// Make sure we have a file to use
if ($handle) {
$rowCount = 0;
while (($data = fgetcsv($handle)) !== false) {
// The first row should be ignored...
if ($rowCount > 0) {
// Clean up the names
$name = str_replace(' ', ' ', $data[0]);
$name = str_replace(' ', ' ', $name);
$name = str_replace(' ', ' ', $name);
$name = trim($name);
$name = ucwords($name);
// Don't use real email addresses in DEV
$email = App::environment() == 'production' ? $data[3] : $faker->safeEmail;
// Clean up the phone number
$phone = preg_replace('~.*(\\d{3})[^\\d]*(\\d{3})[^\\d]*(\\d{4}).*~', '$1-$2-$3', $data[2]);
// Set the address
$address = $data[1];
$customers[] = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'password' => Hash::make('password'));
}
++$rowCount;
}
}
// Close the file
fclose($handle);
foreach ($customers as $customer) {
UserModel::create($customer);
}
}
示例10: createAction
public function createAction()
{
if (!isset($_POST['name']) && !isset($_POST['prenom']) && !isset($_POST['pseudo']) && !isset($_POST['password']) && !isset($_POST['mail'])) {
return json_encode(["error" => "titre_article missing"]);
}
$name = strip_tags($_POST['name']);
$name = htmlentities($name);
$name = trim($name);
$prenom = strip_tags($_POST['prenom']);
$prenom = htmlentities($prenom);
$prenom = trim($prenom);
$pseudo = strip_tags($_POST['pseudo']);
$pseudo = htmlentities($pseudo);
$pseudo = trim($pseudo);
$password = strip_tags($_POST['password']);
$password = htmlentities($password);
$password = trim($password);
$password = sha1($password);
$mail = strip_tags($_POST['email']);
$mail = htmlentities($mail);
$mail = trim($mail);
$user = UserModel::create($this->pdo, $name, $prenom, $pseudo, $password, $mail);
return json_encode(["message" => "Créé !", "name" => $name, "prenom" => $prenom, "pseudo" => $pseudo, "password" => $password, "mail" => $mail]);
}
示例11: users_create
/**
* Creates a new user using the information received in the parameters
*
* @global Array $STRINGS
* @param Array $params
*/
public function users_create($params)
{
global $STRINGS;
$valid = true;
$duplicate = false;
// check all the params
foreach ($params as $param) {
if (empty($param)) {
$valid = false;
break;
}
}
//remove url params
$params = array_slice($params, 2);
// cast the params to object
$user = (object) $params;
//encrypt password
$user->password = sha1($user->password);
// check if the identifier is already registred
if (UserModel::find_by_identifier($user->identifier) == true) {
$duplicate = true;
}
if ($valid && !$duplicate) {
$result = UserModel::create($user);
$result == true ? $alert = BootstrapHelper::alert('success', $STRINGS['event:success'], $STRINGS['user:create:success']) : ($alert = BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:create:failed']));
$this->_data->page = 0;
$this->_data->users = UserModel::find_page(0);
new AdminUsersView($this->_data, $alert);
} else {
if (!$valid && !$duplicate) {
new AdminUserCreateView(null, BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:create:failed']));
} else {
if ($duplicate) {
$this->_data->page = 0;
$this->_data->users = UserModel::find_page(0);
new AdminUsersView($this->_data, BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:create:duplicate']));
}
}
}
}
示例12: testDelete
/**
* Tests the delete method
*/
public function testDelete()
{
//create fake user
$user = new stdClass();
$user->id = '999997';
$user->identifier = 'tester3';
//store the fake user
UserModel::create($user);
//delete the fake user
UserModel::delete('999997');
//check that the user is gone
$this->assertFalse(UserModel::find('999997'));
}
示例13: addResponse
/**
* ��������� ������ ������ ������
* @param $id
* @throws Kohana_Exception
*/
public function addResponse($id)
{
try {
// ���������� �� +1 ����� ���������� ������
$this->_model->total_responses = $this->_totalResponses + 1;
$this->_model->save();
// ���������� �� +1 ����� ���������� �������
$modelAnswer = QuizAnswerModel::find($id);
$modelAnswer->responses_count = $this->_answers[$id]['count'] + 1;
$modelAnswer->save();
UserModel::create(['user_name' => 'TEST', 'ip' => \App::instance()->http()->getIpAddress()]);
// ��������� ������ ������
QuizResponsesModel::create(['user_id' => $this->_userId, 'quiz_id' => $this->_quizId, 'quiz_answer_id' => $id]);
} catch (Exception $e) {
}
// ��������� �������
$this->find();
}
示例14: shebei_save
public function shebei_save()
{
$data['id'] = $this->_post('id');
$data['num'] = $this->_post('num');
$data['home'] = $this->_post('home');
$data['tsj'] = $this->_post('tsj');
$data['xsq'] = $this->_post('xsq');
$shiyong = new UserModel('shiyong');
if (!$shiyong->create()) {
$this->error($shiyong->getError());
} else {
$list = $shiyong->save($data);
if ($list) {
$this->success('修改成功!', U('User/index'));
} else {
$this->error('修改失败!');
}
}
}
示例15: adding
public function adding()
{
$data['username'] = $this->_post('username');
$data['yourname'] = $this->_post('yourname');
$data['password'] = md5($this->_post('password'));
$data['status'] = $this->_post('status');
$user = new UserModel('user');
if (!$user->create()) {
// 如果创建失败 表示验证没有通过 输出错误提示信息
$this->error($user->getError());
} else {
$list = $user->add($data);
$id['role_id'] = $this->_post('role_id');
$id['user_id'] = $list;
$role = M('roleUser')->add($id);
$shiyong = M('shiyong');
$data_id['pid'] = $list;
$data_id['tsj'] = '143';
$data_id['xsq'] = '136';
$slist = $shiyong->add($data_id);
$testuser = M('testuser');
$test['pid'] = $list;
$testlist = $testuser->add($test);
if ($list and $role and $slist and $testlist) {
$this->success('注册成功!', U('User/index'));
} else {
$this->error('注册失败!');
}
}
/*
if($data['username']!='' and $data['yourname']!=''){
if($pwd==$pwds and $pwd!='' and $pwds!=''){
$user = M('user');
$data['password'] = md5($pwds);
$list=$user->data($data)->add();
if($list){
$this->success('添加成功','index');
}else{
$this->error('添加失败,清理联系管理员!');
}
}else{
$this->error('密码有误!!!');
}
}else{
$this->error('员工账号和用户姓名不能为空!!!');
}
*/
}