当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_User::insert方法代码示例

本文整理汇总了PHP中Model_User::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_User::insert方法的具体用法?PHP Model_User::insert怎么用?PHP Model_User::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_User的用法示例。


在下文中一共展示了Model_User::insert方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: add

 /**
  * Add a new admin to the system
  *
  * @param array $args
  * @return void
  */
 public function add(array $args = array())
 {
     $ini = Garp_Auth::getInstance()->getConfigValues();
     if (empty($ini['adapters']['db'])) {
         Garp_Cli::errorOut('Error: DB adapter is not configured in application.ini.');
     } elseif (empty($ini['adapters']['db']['identityColumn']) || empty($ini['adapters']['db']['credentialColumn'])) {
         Garp_Cli::errorOut('Error: identityColumn or credentialColumn not configured in application.ini');
     } else {
         $newUserData = array('role' => 'admin');
         $promptData = array();
         // Pull required fields from Spawner config
         $modelSet = Garp_Spawn_Model_Set::getInstance();
         $userModelConfig = $modelSet['User'];
         $requiredFields = $userModelConfig->fields->getFields('required', true);
         foreach ($requiredFields as $field) {
             if ($field->origin == 'config' && $field->name !== 'id') {
                 $promptData[] = $field->name;
             } elseif ($field->origin == 'relation') {
                 Garp_Cli::errorOut('Field ' . $field->name . ' is required but must be filled by way of relation. ' . 'This makes it impossible to create an admin from the commandline.');
             }
         }
         if (!in_array($ini['adapters']['db']['identityColumn'], $promptData)) {
             $promptData[] = $ini['adapters']['db']['identityColumn'];
         }
         // prompt for the new data
         Garp_Cli::lineOut('Please fill the following columns:');
         foreach ($promptData as $key) {
             $newUserData[$key] = trim(Garp_Cli::prompt($key . ':'));
         }
         $newAuthLocalData = array('password' => trim(Garp_Cli::prompt('Choose a password:')));
         /**
          * A lot of assumptions are made here;
          * - a users table is available, as well as a User model
          * - an auth_local table is available, following the conventions set by Garp
          * - the users table has an id, name, email and role column, while the password
          *   column resides in the auth_local table
          *
          * While all this is the preferred method, it's entirely possible to circumvent these
          * conventions and come up with project-specific standards.
          * In that case however, this CLI command is not for you.
          */
         $user = new Model_User();
         try {
             $id = $user->insert($newUserData);
             $authLocal = new Model_AuthLocal();
             $newAuthLocalData['user_id'] = $id;
             if ($authLocal->insert($newAuthLocalData)) {
                 Garp_Cli::lineOut('Successfully created the administrator. (id: ' . $id . ')');
             } else {
                 Garp_Cli::errorOut('Error: could not create administrator.');
             }
         } catch (Zend_Db_Statement_Exception $e) {
             if (strpos($e->getMessage(), 'Duplicate entry') !== false && strpos($e->getMessage(), 'email_unique') !== false) {
                 Garp_Cli::errorOut('Error: this email address is already in use. ' . 'Maybe you meant to use Garp Admin make?');
             } else {
                 throw $e;
             }
         }
     }
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:66,代码来源:Admin.php

示例2: createNew

 /**
  * Store a new user. This creates a new AuthVimeo record, but also
  * a new user record.
  * @param String $vimeoId Vimeo user id
  * @param Zend_Oauth_Token_Access $accessToken oAuth access token
  * @param Array $props Properties received from Vimeo
  * @return Garp_Db_Table_Row The new user data
  */
 public function createNew($vimeoId, Zend_Oauth_Token_Access $accessToken, array $props)
 {
     // first save the new user
     $userModel = new Model_User();
     $userId = $userModel->insert($props);
     $userData = $userModel->find($userId)->current();
     $this->insert(array('vimeo_id' => $vimeoId, 'access_token' => $accessToken->getToken(), 'access_token_secret' => $accessToken->getTokenSecret(), 'user_id' => $userId));
     $this->getObserver('Authenticatable')->updateLoginStats($userId);
     return $userData;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:18,代码来源:AuthVimeo.php

示例3: createNew

 /**
  * Store a new user. This creates a new auth_openid record, but also
  * a new users record.
  * @param String $openid
  * @param Array $props Properties fetched thru Sreg
  * @return Garp_Db_Table_Row The new user data
  */
 public function createNew($openid, array $props)
 {
     // first save the new user
     $userModel = new Model_User();
     $userId = $userModel->insert($props);
     $userData = $userModel->find($userId)->current();
     $this->insert(array('openid' => $openid, 'user_id' => $userId));
     $this->getObserver('Authenticatable')->updateLoginStats($userId);
     return $userData;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:17,代码来源:AuthOpenId.php

示例4: createNew

 /**
  * Store a new user. This creates a new auth_facebook record, but also
  * a new user record.
  * @param Array $authData Data for the new Auth record
  * @param Array $userData Data for the new User record
  * @return Garp_Db_Table_Row The new user data
  */
 public function createNew(array $authData, array $userData)
 {
     // first save the new user
     $userModel = new Model_User();
     $userId = $userModel->insert($userData);
     $userData = $userModel->find($userId)->current();
     $authData['user_id'] = $userId;
     $this->insert($authData);
     $this->getObserver('Authenticatable')->updateLoginStats($userId);
     return $userData;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:18,代码来源:AuthFacebook.php

示例5: indexAction

 public function indexAction()
 {
     $table = new Model_User();
     //类的实例化
     // 增加的数据
     $data = array('tb_user' => 'King', 'tb_pass' => 'mrsoft');
     if ($table->insert($data)) {
         //执行添加操作
         $this->view->insert = "插入数据成功!";
     }
 }
开发者ID:Arrray,项目名称:PHPpractice,代码行数:11,代码来源:IndexController.php

示例6: createNew

 /**
  * Store a new user. This creates a new auth_linkedin record, but also
  * a new user record.
  * @param String $linkedinId LinkedIn user id
  * @param Array $props Properties received from LinkedIn
  * @return Garp_Db_Table_Row The new user data
  */
 public function createNew($linkedinId, array $props)
 {
     //print($linkedinId . '<pre>' . print_r($props, true));
     // first save the new user
     $userModel = new Model_User();
     $userId = $userModel->insert($props);
     $userData = $userModel->find($userId)->current();
     $this->insert(array('linkedin_uid' => $linkedinId, 'user_id' => $userId));
     $this->getObserver('Authenticatable')->updateLoginStats($userId);
     return $userData;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:18,代码来源:AuthLinkedin.php

示例7: createUser

 /**
  * 建立用户
  */
 public function createUser()
 {
     if ($this->getR('pwd') != $this->getR('pwd1')) {
         return array('status' => -1, 'info' => '密码不一致', 'data' => null);
     }
     $this->_modelUser = $this->getGlobal('model/User', 'Model_User');
     if ($this->_modelUser->findByUser($this->getR('user'))) {
         return array('status' => -1, 'info' => '此账号已存在', 'data' => null);
     }
     $userArr = array('user' => $this->getR('user'), 'vuser' => $this->getR('vuser'), 'pwd' => $this->convertPwd($this->getR('pwd')));
     if ($this->_modelUser->insert($userArr)) {
         $userArr['id'] = $this->_modelUser->getLastInsertId();
         import('object/UserClass');
         $userClass = new UserClass();
         $userClass->create($userArr);
         $userClass->setUpdate(true);
         $userClass = null;
         unset($userClass);
         return array('status' => 1, 'info' => '创建用户成功', 'data' => null);
     } else {
         return array('status' => -2, 'info' => '创建用户失败', 'data' => null);
     }
 }
开发者ID:BGCX261,项目名称:zlskytakeorder-svn-to-git,代码行数:26,代码来源:UserSession.class.php

示例8: registerAction

 /**
  * Register a new account
  *
  * @return void
  */
 public function registerAction()
 {
     $this->view->title = __('register page title');
     $authVars = Garp_Auth::getInstance()->getConfigValues();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     $errors = array();
     $postData = $this->getRequest()->getPost();
     $this->view->postData = $postData;
     // Apply some mild validation
     $password = $this->getRequest()->getPost('password');
     if (!$password) {
         $errors[] = sprintf(__('%s is a required field'), __('Password'));
     }
     $checkRepeatPassword = !empty($authVars['register']['repeatPassword']) && $authVars['register']['repeatPassword'];
     if ($checkRepeatPassword) {
         $repeatPasswordField = $this->getRequest()->getPost($authVars['register']['repeatPasswordField']);
         unset($postData[$authVars['register']['repeatPasswordField']]);
         if ($password != $repeatPasswordField) {
             $errors[] = __('the passwords do not match');
         }
     }
     if (count($errors)) {
         $this->view->errors = $errors;
         return;
     }
     // Save the new user
     $userModel = new Model_User();
     try {
         // Before register hook
         $this->_beforeRegister($postData);
         // Extract columns that are not part of the user model
         $userData = $userModel->filterColumns($postData);
         $insertId = $userModel->insert($userData);
         $this->_helper->flashMessenger(__($authVars['register']['successMessage']));
         // Store new user directly thru Garp_Auth so that they're logged in immediately
         $newUser = $userModel->find($insertId)->current();
         $auth = Garp_Auth::getInstance();
         $auth->store($newUser->toArray(), 'db');
         // After register hook
         $this->_afterRegister();
         // Determine targetUrl.
         // This is the URL the user was trying to access before registering, or a default URL.
         $router = Zend_Controller_Front::getInstance()->getRouter();
         if (!empty($authVars['register']['successRoute'])) {
             $targetUrl = $router->assemble(array(), $authVars['register']['successRoute']);
         } elseif (!empty($authVars['register']['successUrl'])) {
             $targetUrl = $authVars['register']['successUrl'];
         } else {
             $targetUrl = '/';
         }
         $store = Garp_Auth::getInstance()->getStore();
         if ($store->targetUrl) {
             $targetUrl = $store->targetUrl;
             unset($store->targetUrl);
         }
         $this->_redirect($targetUrl);
         // Check for duplication errors in order to show
         // a helpful error to the user.
     } catch (Zend_Db_Statement_Exception $e) {
         if (strpos($e->getMessage(), 'Duplicate entry') !== false && strpos($e->getMessage(), 'email_unique') !== false) {
             $errors[] = __('this email address already exists');
         } else {
             throw $e;
         }
         // Validation errors should be safe to show to the user (note: translation
         // must be done in the validator itself)
     } catch (Garp_Model_Validator_Exception $e) {
         $errors[] = $e->getMessage();
         // Unknown error? Yikes... Show to developers, but show a
         // generic error to the general public.
     } catch (Exception $e) {
         $error = APPLICATION_ENV === 'development' ? $e->getMessage() : __('register error');
         $errors[] = $error;
     }
     $this->view->errors = $errors;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:83,代码来源:AuthController.php

示例9: _createOrFetchUserRecord

 protected function _createOrFetchUserRecord(array $userData)
 {
     $userModel = new Model_User();
     $userData = $userModel->filterColumns($userData);
     $select = $userModel->select()->where('email = ?', $userData['email']);
     if ($userRecord = $userModel->fetchRow($select)) {
         return $userRecord->id;
     }
     return $userModel->insert($userData);
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:10,代码来源:Passwordless.php

示例10: testShouldFailOnStrangersToken

 public function testShouldFailOnStrangersToken()
 {
     if (!$this->_testsEnabled) {
         return;
     }
     $userModel = new Model_User();
     $userModel->insert(array('email' => 'henk@grrr.nl', 'id' => 1));
     $userModel->insert(array('email' => 'jaap@grrr.nl', 'id' => 2));
     $authModel = new Model_AuthPasswordless();
     $authModel->insert(array('token' => '12345', 'token_expiration_date' => date('Y-m-d H:i:s', strtotime('+30 minutes')), 'user_id' => 2));
     $pwless = new Garp_Auth_Adapter_Passwordless();
     $response = $pwless->acceptToken('12345', 1);
     $this->assertFalse($response);
     $this->assertEquals($pwless->getErrors(), array(__('passwordless token not found')));
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:15,代码来源:PasswordlessTest.php

示例11: array

        $sex = global_editor::rteSafe(html_entity_decode($sex, ENT_COMPAT, 'UTF-8'));
        $identity = $_pgR['Identity'];
        $identity = global_editor::rteSafe(html_entity_decode($identity, ENT_COMPAT, 'UTF-8'));
        $roleID = $_pgR['RoleID'];
        $roleID = global_editor::rteSafe(html_entity_decode($roleID, ENT_COMPAT, 'UTF-8'));
        $userRankID = $_pgR['UserRankID'];
        $userRankID = global_editor::rteSafe(html_entity_decode($userRankID, ENT_COMPAT, 'UTF-8'));
        $avatar = $_pgR['Avatar'];
        $avatar = global_editor::rteSafe(html_entity_decode($avatar, ENT_COMPAT, 'UTF-8'));
        $accountID = $_pgR['AccountID'];
        $accountID = global_editor::rteSafe(html_entity_decode($accountID, ENT_COMPAT, 'UTF-8'));
        $isActived = $_pgR['IsActived'];
        $isActived = global_editor::rteSafe(html_entity_decode($isActived, ENT_COMPAT, 'UTF-8'));
        //$strName = $_pgR['name'];
        //$strName = global_editor::rteSafe(html_entity_decode($strName,ENT_COMPAT ,'UTF-8' ));
        $resultID = $objUser->insert($userID, $userName, $password, $fullname, $birthDate, $address, $phone, $email, $sex, $identity, $roleID, $userRankID, $avatar, $accountID, $isActived);
        if ($resultID) {
            $arrHeader = global_common::getMessageHeaderArr($banCode);
            //$banCode
            echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, $result), array(0, 1));
            return;
        } else {
            echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1));
            return;
        }
    } else {
        echo global_common::convertToXML($arrHeader, array("rs", 'info'), array(0, global_common::STRING_REQUIRE_LOGIN), array(0, 1));
    }
    return;
} elseif ($_pgR['act'] == model_User::ACT_UPDATE) {
    if (global_common::isCLogin()) {
开发者ID:roni5,项目名称:sela,代码行数:31,代码来源:admin_user.php


注:本文中的Model_User::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。