本文整理汇总了PHP中Application_Model_User::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_User::insert方法的具体用法?PHP Application_Model_User::insert怎么用?PHP Application_Model_User::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application_Model_User
的用法示例。
在下文中一共展示了Application_Model_User::insert方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signupAction
public function signupAction()
{
$users = new Application_Model_User();
$form = new Application_Form_Registration();
$this->view->form = $form;
// Define a transport and set the destination on the server
// $upload = new Zend_File_Transfer_Adapter_Http();
// $upload->addFilter('Rename', APPLICATION_PATH . '/../data/'.'jpg');
// $upload->addFilter('Rename', APPLICATION_PATH . '/../data/');
// Zend_Debug::dump($upload->getFileInfo());
if ($this->getRequest()->isPost()) {
if ($form->isValid($_POST)) {
// $upload->setDestination('data/');
//
// $upload->receive();
$data = $form->getValues();
$upload = new Zend_File_Transfer_Adapter_Http();
$upload->receive();
if ($data['password'] != $data['confirmPassword']) {
$this->view->errorMessage = "Password and confirm password don't match.";
return;
}
if ($users->checkUnique($data['name'])) {
$this->view->errorMessage = "Name already taken. Please choose another one.";
return;
}
unset($data['confirmPassword']);
$users->insert($data);
echo 'tmaaaaaaaam';
$this->_redirect('auth/login');
echo 'tmaaaaaaaam';
}
}
}
示例2: createAction
/**
* Método usado para cadastrar novos usuários, se receber uma requisição post
* e seus dados forem validados, é criado um registro de usuário e redirecionado Método retrieve
* @method createAction
* @access public
* @return resource
*/
public function createAction()
{
$form = new Application_Form_User();
$user = new Application_Model_User();
if ($this->_request->isPost()) {
if ($form->isValid($this->_request->getPost())) {
$user->insert($form->getValues());
$this->_redirect('/user/retrieve');
} else {
$form->populate($form->getValues());
}
}
$this->view->form = $form;
}
示例3: registerAction
function registerAction()
{
$user = new Application_Model_User();
$this->view->form = new Application_Form_Register();
if ($this->_request->isPost()) {
Zend_Loader::loadClass('Zend_Filter_StripTags');
$filter = new Zend_Filter_StripTags();
$name = trim($filter->filter($this->_request->getPost('name')));
$pass = trim($filter->filter($this->_request->getPost('pass')));
$email = trim($filter->filter($this->_request->getPost('email')));
$pass = md5($pass);
$userRow = $user->fetchRow($user->select()->where('name = ?', $name));
//$userArray = $userRow->toArray();
if ($userRow != '') {
echo "User name already exist";
} else {
$userRow = $user->fetchRow($user->select()->where('email = ?', $email));
//$userArray = $userRow->toArray();
if ($userRow != '') {
echo "Email already exist";
} else {
if ($this->view->form->isValid($this->getRequest()->getPost())) {
$hash = md5(microtime());
$mail = new Zend_Mail();
$mail->setBodyText('Hello
Your email regisrated on website spitfire.mydev.org.ua
to confirm your account click link bellow
http://spitfire.mydev.org.ua/register/confirmuser/&hash=<');
$mail->setFrom('spitfire.net@gmail.com', 'Some Sender');
$mail->addTo('spitfire.ukr@gmail.com', 'Some Sender');
$mail->setSubject('TestSubject');
$mail->send();
if ($name != '' && $pass != '') {
$data = array('name' => $name, 'email' => $email, 'pass' => $pass);
$user->insert($data);
$this->_redirect('/');
return;
}
} else {
echo "Captcha wrong";
}
}
}
}
}
示例4: save
/**
* This method is used to save the new patient or update the information of
* an existing patient. a user with the mrn.no is create with the username and
* password same as mrn. no.
* it also enters the order of patient
* @param type $dataPosted
* @return array id of patient and order
*/
public function save($dataPosted)
{
$userObj = new Application_Model_User();
$arrayCols = $userObj->fetchNew()->toArray();
$patientObj = new Application_Model_Patient();
$arrayColsPat = $patientObj->fetchNew()->toArray();
$dataPosted['updated_at'] = date('Y-m-d H:i:s');
$dataPosted['created_at'] = date('Y-m-d H:i:s');
$user_data = array_intersect_key($dataPosted, $arrayCols);
// filter the posted data to model attributes
$patient_data = array_intersect_key($dataPosted, $arrayColsPat);
unset($patient_data['id']);
$user_data['username'] = $dataPosted['m_r_no'];
$user_data['password'] = md5($dataPosted['m_r_no']);
$user_data['user_type'] = 'patient';
//update user and patient if id passed
if (!empty($user_data['id'])) {
unset($user_data['created_at']);
unset($patient_data['created_at']);
$userObj->update($user_data, 'id=' . $user_data['id']);
$user_id = $user_data['id'];
$patient_data['user_id'] = $user_id;
$patientObj->update($patient_data, 'user_id=' . $user_id);
} else {
//insert new user and patient if id not passed
unset($user_data['id']);
$user_id = $userObj->insert($user_data);
$patient_data['user_id'] = $user_id;
$patientObj->insert($patient_data);
}
$result['id'] = $user_id;
$result['order_id'] = '';
// Save patient Tests
$patient_orders_obj = new Application_Model_DbTable_PatientOrders();
if (isset($dataPosted['test_id'])) {
$testIds = $dataPosted['test_id'];
} else {
$testIds = [];
}
if (!empty($dataPosted['order_id']) || count($testIds)) {
if (empty($dataPosted['order_id'])) {
$dataOrder['user_id'] = $user_id;
$dataOrder['created_at'] = date('Y-m-d H:i:s');
$dataOrder['total_tests'] = count($testIds);
$order_id = $patient_orders_obj->insert($dataOrder);
} else {
$order_id = $dataPosted['order_id'];
$dataOrder['total_tests'] = count($testIds);
$patient_orders_obj->update($dataOrder, 'id = ' . $order_id);
}
$result['order_id'] = $order_id;
// Delete the removed tests
$OrderTestsObj = new Application_Model_DbTable_OrderTests();
$oldTests = $OrderTestsObj->fetchAll('order_id = ' . $order_id);
$oldTestsArr = [];
foreach ($oldTests as $oldTest) {
if (!in_array($oldTest['test_id'], $testIds)) {
$OrderTestsObj->delete('test_id = ' . $oldTest['test_id'] . ' and order_id = ' . $order_id);
}
$oldTestsArr[] = $oldTest['test_id'];
}
// Add new tests
foreach ($testIds as $newTest) {
if (!in_array($newTest, $oldTestsArr)) {
$OrderTestsObj->insert(['test_id' => $newTest, 'order_id' => $order_id]);
}
}
}
return $result;
}
示例5: editAction
/**
* 编辑员工信息
*/
public function editAction()
{
// 返回值数组
$result = array('success' => true, 'info' => '编辑成功');
$request = $this->getRequest()->getParams();
$now = date('Y-m-d H:i:s');
$user_session = new Zend_Session_Namespace('user');
$user_id = $user_session->user_info['user_id'];
$json = json_decode($request['json']);
$updated = $json->updated;
$inserted = $json->inserted;
$deleted = $json->deleted;
$employee = new Hra_Model_Employee();
$user = new Application_Model_User();
if (count($updated) > 0) {
foreach ($updated as $val) {
if ($employee->fetchAll("id != " . $val->id . " and email = '" . $val->email . "'")->count() > 0) {
$result['success'] = false;
$result['info'] = '更新失败,邮箱地址重复!';
echo Zend_Json::encode($result);
exit;
} else {
if ($employee->fetchAll("id != " . $val->id . " and number = '" . $val->number . "'")->count() > 0) {
$result['success'] = false;
$result['info'] = '更新失败,工号重复!';
echo Zend_Json::encode($result);
exit;
} else {
$dept_manager_id = $val->dept_manager_id == '' ? null : $val->dept_manager_id;
$manager_id = $val->manager_id == '' ? null : $val->manager_id;
$dept_id = $val->dept_id == '' ? null : $val->dept_id;
$post_id = $val->post_id == '' ? null : $val->post_id;
$area_id = $val->area_id == '' ? null : $val->area_id;
$professional_qualifications_id = $val->professional_qualifications_id == '' ? null : $val->professional_qualifications_id;
$data = array('hide' => $val->hide, 'active' => $val->active, 'leader' => $val->leader, 'number' => $val->number, 'cname' => $val->cname, 'ename' => $val->ename, 'sex' => $val->sex, 'birthday' => $val->birthday, 'id_card' => $val->id_card, 'dept_id' => $dept_id, 'post_id' => $post_id, 'area_id' => $area_id, 'professional_qualifications_id' => $professional_qualifications_id, 'dept_manager_id' => $dept_manager_id, 'manager_id' => $manager_id, 'salary' => $val->salary, 'email' => $val->email, 'tel' => $val->tel, 'official_qq' => $val->official_qq, 'work_place' => $val->work_place, 'short_num' => $val->short_num, 'msn' => $val->msn, 'address' => $val->address, 'remark' => $val->remark, 'marital_status' => $val->marital_status, 'marry_day' => $val->marry_day, 'children_birthday' => $val->children_birthday, 'insurcode' => $val->insurcode, 'accumulation_fund_code' => $val->accumulation_fund_code, 'education' => $val->education, 'school' => $val->school, 'major' => $val->major, 'entry_date' => $val->entry_date, 'regularization_date' => $val->regularization_date, 'labor_contract_start' => $val->labor_contract_start, 'labor_contract_end' => $val->labor_contract_end, 'offical_address' => $val->offical_address, 'other_contact' => $val->other_contact, 'other_relationship' => $val->other_relationship, 'other_contact_way' => $val->other_contact_way, 'work_years' => $val->work_years, 'politics_status' => $val->politics_status, 'employment_type' => $val->employment_type, 'leave_date' => $val->leave_date, 'ext' => $val->ext, 'driving_license' => $val->driving_license, 'salary' => $val->salary, 'bank' => $val->bank, 'bank_num' => $val->bank_num, 'update_time' => $now, 'update_user' => $user_id);
$where = "id = " . $val->id;
try {
$employee->update($data, $where);
} catch (Exception $e) {
$result['success'] = false;
$result['info'] = $e->getMessage();
echo Zend_Json::encode($result);
exit;
}
if ($val->account == 1) {
if ($user->fetchAll("employee_id = " . $val->id)->count() > 0) {
$account_active = $val->account_active == true ? 1 : 0;
// 当员工系统账号已存在时,如需要改变账号状态,则更新系统账号状态信息
if ($user->fetchAll("active = " . $account_active . " and employee_id = " . $val->id)->count() == 0) {
try {
$user->update(array('active' => $account_active, 'update_user' => $user_id, 'update_time' => $now), "employee_id = " . $val->id);
} catch (Exception $e) {
$result['success'] = false;
$result['info'] = $e->getMessage();
echo Zend_Json::encode($result);
exit;
}
}
} else {
// 当员工系统账号不存在时,则添加新的系统账号信息
$data = array('employee_id' => $val->id, 'active' => $val->account_active, 'password' => md5($val->number . '123456'), 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
try {
$newUserId = $user->insert($data);
// 初始化用户角色为普通用户
$roleMember = new Admin_Model_Member();
try {
$roleMember->insert(array('user_id' => $newUserId));
} catch (Exception $e) {
$result['success'] = false;
$result['info'] = $e->getMessage();
echo Zend_Json::encode($result);
exit;
}
} catch (Exception $e) {
$result['success'] = false;
$result['info'] = $e->getMessage();
echo Zend_Json::encode($result);
exit;
}
}
} else {
if ($user->fetchAll("employee_id = " . $val->id)->count() > 0) {
// 当员工系统账号已存在时,如需要改变账号状态,则更新系统账号状态信息
if ($user->fetchAll("active = " . $val->account_active . " and employee_id = " . $val->id)->count() == 0) {
try {
$user->update(array('active' => $val->account_active, 'update_user' => $user_id, 'update_time' => $now), "employee_id = " . $val->id);
} catch (Exception $e) {
$result['success'] = false;
$result['info'] = $e->getMessage();
echo Zend_Json::encode($result);
exit;
}
}
}
}
}
}
//.........这里部分代码省略.........