本文整理汇总了PHP中UserModel::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::insert方法的具体用法?PHP UserModel::insert怎么用?PHP UserModel::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerAction
/**
* 确认注册【设定密码】
* @method registerAction
* @return [type] [description]
* @author NewFuture
*/
public function registerAction()
{
$msg = '信息注册失败!';
if ($regInfo = Session::get('reg')) {
Session::del('reg');
if (Input::post('password', $password, 'trim') === false) {
/*密码未md5*/
$this->error('密码错误', '/');
} elseif (!$password) {
/*未设置密码*/
$password = $regInfo['password'];
}
$regInfo['password'] = Encrypt::encryptPwd($password, $regInfo['number']);
if ($id = UserModel::insert($regInfo)) {
/*注册成功*/
$regInfo['id'] = $id;
$token = Auth::token($regInfo);
Cookie::set('token', [$id => $token]);
unset($regInfo['password']);
Session::set('user', $regInfo);
$msg = '信息注册成功!';
}
}
$this->jump('/', $msg);
}
示例2: POST_indexAction
/**
* 注册
* @method POST_indexAction
* @param string $name [description]
* @return [type] [description]
* @author NewFuture
*/
public function POST_indexAction()
{
if (!($regInfo = Session::get('reg'))) {
$this->response(0, '注册信息失效');
} else {
/*检查密码*/
if (Input::post('password', $password, 'isMD5')) {
$msg = '成功设置了新的密码作为云印密码!';
} else {
$msg = '使用刚才的验证密码作为运用登陆密码!';
$password = $regInfo['password'];
}
/*开始注册*/
$regInfo['password'] = Encrypt::encryptPwd($password, $regInfo['number']);
if ($id = UserModel::insert($regInfo)) {
/*注册成功*/
$msg .= '(如果下次忘记密码后可以通过 手机,邮箱或者再次认证找回密码)';
$regInfo['id'] = $id;
$token = Auth::token($regInfo);
Cookie::set('token', $token);
unset($regInfo['password']);
Session::del('reg');
Session::set('user', $regInfo);
$this->response(1, ['user' => $regInfo, 'token' => $token, 'msg' => $msg]);
} else {
$this->response(0, '注册失败');
}
}
}
示例3: addUser
/**
* 添加用户
* @param $name
* @param $email
* @param $pwd
*/
public function addUser($name, $email, $pwd)
{
//TODO:datacheck
$where = ['OR' => ['name' => $name, 'email' => $email], 'LIMIT' => [1]];
$result = $this->userDao->select(['name', 'email'], $where);
foreach ($result as $item) {
if ($item['name'] == $name) {
throw new \InvalidArgumentException('该用户名已被注册');
}
if ($item['email'] == $email) {
throw new \InvalidArgumentException('该邮箱已被注册');
}
}
$result = $this->userDao->insert(['name' => $name, 'email' => $email, 'pwd' => md5($pwd), 'ctime' => time()]);
if ($result === false) {
throw new \Exception('无法创建用户');
}
return true;
}
示例4: createAccountAction
public function createAccountAction()
{
// Load model can thiet
Zend_Loader::loadClass("UserModel");
Zend_Loader::loadClass("RandomStringModel");
//Lay va xu ly tham so
$params = $this->_arrParam;
if ($this->_request->isPost()) {
if (isset($params['email']) && !empty($params['platform']) && !empty($params['user_name']) && !empty($params['password'])) {
$user_model = new UserModel();
if (strlen($params['user_name']) >= 1 && strlen($params['user_name']) <= 12) {
if (strlen($params['password']) >= 6 && strlen($params['password']) <= 50) {
$result = $user_model->checkAccountExist($params['user_name'], $params['email']);
if ($result) {
// User moi
$data = array("user_name" => $params['user_name'], "password" => md5($params['password']), "email" => $params['email'], "user_gome" => 1000, "temp_gome" => 0, "is_vip" => 0, 'daily_gift' => date("Y-m-d", time() - 86400), "status" => ACTIVE_STATUS);
try {
$id = $user_model->insert($data);
if (!empty($params['email'])) {
// Gui mail ve email nguoi dung de thong bao dang ki thanh cong neu co email gui len
$html = "<div>Bạn đã đăng kí thành công tài khoản tại hệ thống game Zegome<br/>";
$html .= "Tên tài khoản: " . $params['user_name'];
$html .= "<br/><p align='center'><i>Liên hệ với chúng tôi: <b>Zero team</b><br/>";
$html .= ADDRESS_ZEGOME . "<br/>";
$html .= "Email: " . EMAIL_ZEGOME . " - Tel: " . PHONE_ZEGOME . ".</i></p></div>";
// Gui mail
$mail = new Zend_Mail('UTF-8');
$mail->setBodyHtml($html);
$mail->addTo($params['email']);
$mail->addCc(EMAIL_ADMIN);
$mail->setSubject('Đăng kí tài khoản tại hệ thống game Zegome');
$mail->send();
}
$data = array("code" => 1, "content" => "Success");
} catch (exception $e) {
$data = array("code" => 0, "content" => "Error in server");
}
} else {
$data = array("code" => 0, "content" => "Duplicate data");
}
} else {
$data = array("code" => 0, "content" => "password ít nhất 6 kí tự");
}
} else {
$data = array("code" => 0, "content" => "user_name nhiều nhất là 12 kí tự");
}
} else {
$data = array("code" => 0, "content" => "Invalid parameters");
}
echo json_encode($data);
}
exit;
}
示例5: expertregisterAction
public function expertregisterAction()
{
$account = $this->getRequest()->getParam('account');
$password = $this->getRequest()->getParam('password');
$name = $this->getRequest()->getParam('name');
$content = $this->getRequest()->getParam('context');
$work = $this->getRequest()->getParam('work');
$code = $this->getRequest()->getParam('surecode');
if ($code == $_SESSION["validcode"]) {
$User = new UserModel();
if ($User->ifRegister($account)) {
$set = array('account' => $account, 'password' => $password, 'name' => $name, 'email' => $account, 'type' => 2);
//在注册用户的时候顺带着要建一个用户个人信息
if ($User->insert($set) > 0) {
$where = "email='{$account}'";
$result = $User->fetchAll($where)->toArray();
$info = array('userid' => $result[0][id], 'sex' => 'M', 'name' => $result[0][name], 'sheng' => '北京市', 'shi' => '北京市', 'xian' => '东城区', 'birth' => '1994-5-29', 'interest' => '跑步');
$userinfo = new userinfoModel();
$expert = array('info' => $content, 'userid' => $result[0][id], 'work' => $work, 'concern' => 0, 'image' => '/WebOne/public/image/initial.png');
$expertinfo = new expertinfoModel();
if ($userinfo->insert($info) > 0 && $expertinfo->insert($expert) > 0) {
//注册账号成功
$this->render('ok');
}
} else {
$this->view->info = '1';
$this->_forward('error');
}
} else {
$this->view->info = '2';
//账号已经创建
$this->_forward('error');
}
} else {
$this->view->info = '3';
$this->render('error');
//验证码输入错误
}
}
示例6: addAction
/**
* 添加
*
*/
public function addAction()
{
// 实例化Model
$user = new UserModel();
// 处理post数据
if ($this->getRequest()->isPost()) {
// 获取所有post数据
$pdata = $this->getAllPost();
// 处理图片等特殊数据
// 验证
$result = $user->validation->validate($pdata, 'add');
$user->parseAttributes($pdata);
// 通过验证
if ($result) {
// 入库前数据处理
// Model转换成数组
$data = $user->toArray($pdata);
$result = $user->insert($data);
if ($result) {
// 提示信息并跳转到列表
Tools_help::setSession('Message', '添加成功!');
$this->redirect('/backend/user/index');
} else {
// 验证失败
$this->_view->assign('ErrorMessage', '添加失败!');
$this->_view->assign("errors", $user->validation->getErrorSummary());
}
} else {
// 验证失败
$this->_view->assign('ErrorMessage', '添加失败!');
$this->_view->assign("errors", $user->validation->getErrorSummary());
}
}
// 格式化表单数据
// 模版分配数据
$this->_view->assign("user", $user);
$this->_view->assign("pageTitle", '添加');
}
示例7: exeUserRegister
/**
* API:用户注册
*
* @access public
* @param 无
* @return JsonView 响应json
*/
public function exeUserRegister()
{
$requestParam = $this->getAllParameters();
Logger::debug('requestParam:' . print_r($requestParam, true));
$requestJsonParam = $this->getDecodedJsonRequest();
Logger::debug('requestJsonParam:' . print_r($requestJsonParam, true));
// 检测账号是否重复
$ret = AuthModel::checkUserAccount($requestJsonParam['account']);
if (!$ret) {
$view = new JsonView();
$messageArr['error'] = "该账号已存在";
return $this->getViewByJson($view, $messageArr, 0, "auth/user_register");
}
// 检测账号是否重复
$ret = AuthModel::checkUserName($requestJsonParam['user_name']);
if (!$ret) {
$view = new JsonView();
$messageArr['error'] = "该昵称已存在";
return $this->getViewByJson($view, $messageArr, 0, "auth/user_register");
}
// 插入新用户
$ret = AuthModel::insert(array('s_account' => $requestJsonParam['account'], 's_password' => $requestJsonParam['password'], 't_create_time' => date("Y-m-d H:i:s")), $pdo);
if (is_null($ret)) {
throw new ModelException('insert false pa_user_master');
}
//---------------------------- 初始用户表 ----------------------------
$user_id = AuthModel::getUserID($requestJsonParam['account'], $requestJsonParam['password'], $pdo);
$messageArr['n_id'] = $user_id;
self::$userBasicIni['s_name'] = $requestJsonParam['user_name'];
self::$userBasicIni['n_sex'] = $requestJsonParam['sex'];
self::$userBasicIni['t_create_time'] = date("Y-m-d H:i:s");
// 初始化关卡信息
$checkPointIni = array(1 => array('score' => 0, 'scr_length' => 0, 'reward' => 0, 'kill_num' => 0, 'star_num' => 0));
//self::$userBasicIni['s_checkpoint_info'] = serialize( $checkPointIni );
// 初始化角色信息
self::$userBasicIni['s_role_info '] = CharacterAction::registCharacter($user_id, Constants::INI_CHARACTER_ID);
// 初始化武将信息
self::$userBasicIni['s_general_info'] = GeneralAction::registGeneral($user_id, Constants::INI_GENERAL_ID);
// 初始化任务信息
self::$userBasicIni['s_task_info'] = serialize(TaskAndAchieveAction::randTask($user_id));
// 初始化成就信息
self::$userBasicIni['s_achievement_info'] = TaskAndAchieveAction::registAchieveCsv($user_id);
// 初始化签到信息
$loginInfo = UserAction::getUserLoginInfo();
self::$userBasicIni['s_login_info'] = serialize($loginInfo);
$userInfo = array_merge($messageArr, self::$userBasicIni);
$ret = UserModel::insert($userInfo, $pdo);
FriendModel::insert(array('n_user_id' => $user_id, 'n_friend_id' => Constants::ROBERT, 't_create_time' => date("Y-m-d H:i:s")));
$battle = UserAction::getUserbattle($user_id);
UserModel::update(array('n_battle' => $battle), array('n_id' => $user_id));
MailAction::sendSystemMail($user_id);
if (is_null($ret)) {
throw new ModelException('insert false pa_user_master');
}
// // 成就
// $statisticArr['login_day'] = 1;
// TaskAndAchieveAction::achieveStatistic( $user_id, $statisticArr );
$userInfo = array_merge($messageArr, self::$userBasicIni);
$session_key = CharacterModel::setSessionKey($user_id, $session_key);
$messageArr['total_day'] = $loginInfo['total_day'];
$messageArr['session_key'] = $session_key;
$view = new JsonView();
return $this->getViewByJson($view, $messageArr, 1, "auth/user_register");
}
示例8: regAction
public function regAction()
{
$p = $_REQUEST;
$pPhone = empty($p['phone']) ? '' : trim($p['phone']);
$pPassword = empty($p['ptxt']) ? '' : trim($p['ptxt']);
#客户端发送的必须是md5的 密码
$pCode = empty($p['code']) ? '0' : trim($p['code']);
$pDid = empty($p['did']) ? '' : trim($p['did']);
$tTime = time();
if (empty($pPassword)) {
Tool_Fnc::ajaxMsg('密码不能为空');
}
if (empty($pCode)) {
Tool_Fnc::ajaxMsg('验证码不能为空');
}
if (!Tool_Validate::integer($pCode)) {
Tool_Fnc::ajaxMsg('验证码格式错误');
}
if (strlen($pPassword) != 32) {
Tool_Fnc::ajaxMsg('接口发送的必须是密文密码');
}
if (empty($pDid) || !Tool_Validate::az09($pDid)) {
Tool_Fnc::ajaxMsg('did error');
}
$tUMO = new UserModel();
$tRow = $tUMO->field('count(0) c')->where('phone = \'' . $pPhone . '\'')->fRow();
if (!empty($tRow['c'])) {
Tool_Fnc::ajaxMsg('该手机已被他人使用,请重新输入');
}
$tUMO = new UserModel();
$tKey = Tool_Fnc::newrand(4);
$tMd5str = Tool_Fnc::markmd5($pPassword, $tKey);
$tCodeMO = new PhonecodeModel();
$tCodeCRow = $tCodeMO->check($pPhone, 1, $pCode);
if ($tCodeCRow['status'] == 0) {
Tool_Fnc::ajaxMsg($tCodeCRow['msg']);
}
$pSex = !isset($p['sex']) ? Tool_Fnc::ajaxMsg('请填写性别') : intval($p['sex']);
$pDryWeight = !isset($p['dry_weight']) ? Tool_Fnc::ajaxMsg('请填写干体重') : floatval($p['dry_weight']);
$pDateOfBirth = empty($p['date_of_birth']) ? Tool_Fnc::ajaxMsg('请填写出生日期') : trim($p['date_of_birth']);
if (!empty($pDateOfBirth) && !Tool_Validate::is_date($pDateOfBirth)) {
Tool_Fnc::ajaxMsg('日期格式不正确');
}
$tData = array('phone' => $pPhone, 'reg_ip' => Tool_Fnc::realip(), "passwd" => $tMd5str, "reg_time" => $tTime, 'private_key' => $tKey, 'reg_did' => $pDid, 'user_type' => 0, 'sex' => $pSex, 'dry_weight' => $pDryWeight, 'date_of_birth' => $pDateOfBirth, 'reg_did' => $pDid);
if (!($tID = $tUMO->insert($tData))) {
Tool_Fnc::ajaxMsg('注册失败');
}
//did入库
$tUDMO = new UserdidModel();
$tUDRow = $tUDMO->field('count(0) c')->where('uid = ' . $tID . ' and did = \'' . $pDid . '\'')->fRow();
if (empty($tUDRow['c'])) {
$tData = array('uid' => $tID, 'did' => $pDid, 'created' => $tTime, 'ip' => Tool_Fnc::realip());
$tUDMO->insert($tData);
}
$tTokenarr = $this->creattoken($tID);
//干重记录表数据更新
$tDWMO = new DryweightlogModel();
$tDryWeightLog = array('uid' => $tID, 'weight' => $pDryWeight, 'date' => date('Y-m-d'), 'month' => date('Y-m'), 'year' => date('Y'), 'created' => $tTime);
$tDWMO->insert($tDryWeightLog);
//匿名转实名
$tUMO->incognito_real($pDid, $tID);
$tTokenarr = array_merge($tTokenarr, array('user_type' => 0));
Tool_Fnc::ajaxMsg('注册成功', 1, $tTokenarr);
}
示例9: register
public function register(array $me)
{
$last_id = UserModel::insert(array('login' => $me['email'], 'fbuid' => $me['id'], 'name' => $me['first_name'], 'surname' => $me['last_name'], 'activate' => 1, 'password' => Tools::random(12), 'newsletter' => 0, 'iso' => 'SVK'));
return UserModel::get($last_id);
}
示例10: UserModel
require_once '../application/UserModel.php';
require_once '../application/User.php';
$userModel = new UserModel();
$user = new User();
// handle action
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action) {
case 'create':
// TODO: data validation
// populate input from user
$user->setFirstName($_POST['first_name']);
$user->setLastName($_POST['last_name']);
$user->setUsername($_POST['username']);
$user->setPassword($_POST['password']);
// save to database
if ($userModel->insert($user)) {
header('location:../index.php?action=create&status=success');
} else {
// TODO: populate last inputs to session
// return back to form
header('location:../form.php?action=create&status=failed');
}
break;
case 'edit':
// TODO: data validation
// populate input from user
$user->setId($_POST['id']);
$user->setFirstName($_POST['first_name']);
$user->setLastName($_POST['last_name']);
$user->setUsername($_POST['username']);
$user->setPassword($_POST['password']);
示例11: addEditOnFormSubmitted
public function addEditOnFormSubmitted(NAppForm $form)
{
$error = false;
dibi::begin();
// add action
if ($this->getAction() == 'add') {
try {
$values = $form->getValues();
$roles = $values['roles'];
unset($values['password2'], $values['roles']);
// $values['password'] = md5($values['password']);
// dibi::query('INSERT INTO ['.TABLE_USERS.'] %v;', $values);
$user_id = UserModel::insert($values);
if (count($roles)) {
foreach ($roles as $role) {
dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $user_id, $role);
}
}
$this->flashMessage('The user has been added.', 'ok');
dibi::commit();
if (ACL_CACHING) {
unset($this->cache['gui_acl']);
// invalidate cache
}
$this->redirect('Users:');
} catch (Exception $e) {
$error = true;
$form->addError('The user has not been added.');
throw $e;
}
} else {
// edit action
$id = $this->getParam('id');
try {
$values = $form->getValues();
$roles = $values['roles'];
unset($values['roles']);
unset($values['password2']);
// dibi::query('UPDATE ['.TABLE_USERS.'] SET %a WHERE id=%i;', $values, $id);
UserModel::update($id, $values);
dibi::query('DELETE FROM [' . TABLE_USERS_ROLES . '] WHERE user_id=%i;', $id);
if (count($roles)) {
foreach ($roles as $role) {
dibi::query('INSERT INTO [' . TABLE_USERS_ROLES . '] (user_id, role_id) VALUES (%i, %i);', $id, $role);
}
}
$this->flashMessage('The user has been edited.', 'ok');
dibi::commit();
if (ACL_CACHING) {
unset($this->cache['gui_acl']);
// invalidate cache
}
$this->redirect('Users:');
} catch (Exception $e) {
$error = true;
$form->addError('The user has not been edited.');
throw $e;
}
}
if ($error) {
dibi::rollback();
}
}
示例12: catch
$cassandra->useKeyspace('CassandraRowsPaginationExample');
} catch (Exception $e) {
// create a new keyspace, accepts extra parameters for replication options
// normally you don't do it every time
$cassandra->createKeyspace('CassandraRowsPaginationExample');
// use the keyspace again properly
$cassandra->useKeyspace('CassandraRowsPaginationExample');
// create a standard column family with given column metadata
$cassandra->createStandardColumnFamily('CassandraRowsPaginationExample', 'user', array(array('name' => 'name', 'type' => Cassandra::TYPE_UTF8, 'index-type' => Cassandra::INDEX_KEYS, 'index-name' => 'NameIdx'), array('name' => 'email', 'type' => Cassandra::TYPE_UTF8), array('name' => 'age', 'type' => Cassandra::TYPE_INTEGER, 'index-type' => Cassandra::INDEX_KEYS, 'index-name' => 'AgeIdx')));
$columns = array('name' => 'Columns test', 'age' => 99, 'email' => 'columns-test@cpcl.com');
// create some example data
for ($i = 0; $i < 1000; $i++) {
UserModel::insert('user-' . sprintf('%04d', $i), array('name' => 'User #' . $i, 'age' => round($i / 10), 'email' => 'user-' . $i . '@cpcl.com'));
$columns[] = 'Column #' . $i;
}
UserModel::insert('columns-test', $columns);
}
echo '<pre>';
/*
$firstUser = UserModel::load('user-0000');
print_r($firstUser->getData());
*/
$reverse = false;
$start = null;
if (isset($_GET['next'])) {
$start = $_GET['next'];
} else {
if (isset($_GET['previous'])) {
$reverse = true;
if (isset($_SESSION['start-' . $_GET['previous']])) {
$start = $_SESSION['start-' . $_GET['previous']];
示例13: testRowsCanBeRemoved2
public function testRowsCanBeRemoved2()
{
UserModel::insert('dave', array('email' => 'dave@gmail.com', 'name' => 'Dave', 'age' => 33));
$dave = UserModel::load('dave');
$this->assertEquals($dave->email, 'dave@gmail.com');
$this->assertEquals($dave->name, 'Dave');
$this->assertEquals($dave->age, 33);
$dave->delete();
$dave2 = UserModel::load('dave');
$this->assertNull($dave2);
}
示例14: saveRegistration
function saveRegistration(NFORM $form)
{
$values = (array) $form->getValues();
$user = UserModel::getFluent(false)->where(' login = %s', $values['login'])->fetch();
try {
if ($user and $user['login'] == $values['login']) {
throw new InvalidStateException(_('Uživateľ pod týmto prihlasovacím meno už existuje.'));
}
// if($user AND $user['email'] == $values['email'])
// throw new InvalidStateException( _('Emailová adresa sa už nachádza v databáze. ') );
//
unset($values['passwordCheck']);
unset($values['terms_and_conditions']);
$values['activate'] = 1;
//registrovany dostane automaticky 2% zlavu
$values['discount'] = 2;
UserModel::insert($values);
$this->flashMessage("Registrácia je dokončená, účet aktivovaný a ste prihlásený na stránke.");
$template = clone $this->template;
$template->setFile(APP_DIR . '/FrontModule/templates/Profil/registrationConfirmEmail.phtml');
$template->values = $values;
$mail = new MyMail();
$mail->addTo($values['login']);
$mail->addBcc(NEnvironment::getVariable('error_email'));
$mail->setSubject(_('Informácie o účte'));
$mail->setTemplate($template);
$mail->send();
$this->user->login($values['login'], $values['password']);
if ($this->backlink != '') {
$this->restoreRequest($this->backlink);
} else {
$this->redirect('Homepage:default');
}
} catch (InvalidStateException $e) {
$form->addError($e->getMessage());
// throw $e;
}
}
示例15: dirname
<?php
header("Content-Type: text/html; charset=utf-8");
require dirname(__FILE__) . '/includes/init.php';
require dirname(__FILE__) . '/includes/ao/OrderAO.php';
$a = cls_sqlexecute::getInstance('mmall_0000', $user_multiple_dbroute_config);
$b = cls_sqlexecute::getInstance('mmall_0001', $user_multiple_dbroute_config);
$c = cls_sqlexecute::getInstance('mmall_0002', $user_multiple_dbroute_config);
print_r($a->getList());
$c = cls_sqlexecute::getInstance('mmall_0003', $user_multiple_dbroute_config);
print_r($a->getList());
die;
$userModel = new UserModel();
print_r($userModel->insert());
echo "====";
die;
$m = new RefundInfoModel();
print_r($m->insert(10, 1));
die;
print_r($userModel->getTableNameBytUserName("abc713807"));
//print_r($userModel->getRow('abc291901'));
//print_r($userModel->getOne('abc291901'));
//print_r($userModel->update('abc291901','new_pwd'));
//print_r($userModel->queryAll('abc'));
//print_r($userModel->queryAllByIn('abc'));
//print_r($userModel->transactionTest('user_name'));
//print_r($userModel->delete('abc291901'));
//die;