當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UserAccount::getAllByCriteria方法代碼示例

本文整理匯總了PHP中UserAccount::getAllByCriteria方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserAccount::getAllByCriteria方法的具體用法?PHP UserAccount::getAllByCriteria怎麽用?PHP UserAccount::getAllByCriteria使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UserAccount的用法示例。


在下文中一共展示了UserAccount::getAllByCriteria方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getUsers

 /**
  * Getting the list of users
  * 
  * @param unknown $sender
  * @param unknown $params
  * 
  * @throws Exception
  */
 public function getUsers($sender, $param)
 {
     $results = $errors = array();
     try {
         if (!isset($param->CallbackParameter->searchCriteria) || ($serachCriteria = trim($param->CallbackParameter->searchCriteria)) === '') {
             $serachCriteria = '';
         }
         $pageNo = 1;
         $pageSize = DaoQuery::DEFAUTL_PAGE_SIZE;
         if (isset($param->CallbackParameter->pagination)) {
             $pageNo = $param->CallbackParameter->pagination->pageNo;
             $pageSize = $param->CallbackParameter->pagination->pageSize;
         }
         $where = '`ua`.id != :sysId';
         $params = array('sysId' => UserAccount::ID_SYSTEM_ACCOUNT);
         if ($serachCriteria !== '') {
             UserAccount::getQuery()->eagerLoad("UserAccount.person", 'inner join', 'ord', '`p`.id = `ua`.personId and (`p`.firstName like :firstName and `p`.lastName like :lastName)');
             $params['firstName'] = $serachCriteria . '%';
             $params['lastName'] = $serachCriteria . '%';
             $where .= ' OR `ua`.username like :username';
             $params['username'] = $serachCriteria . '%';
         }
         $stats = array();
         $users = UserAccount::getAllByCriteria($where, $params, true, $pageNo, $pageSize, array(), $stats);
         $results['pageStats'] = $stats;
         $results['items'] = array();
         foreach ($users as $item) {
             $results['items'][] = $item->getJson();
         }
     } catch (Exception $ex) {
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:42,代碼來源:UsersController.php

示例2: saveUser

 public function saveUser($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->firstName) || ($firstName = trim($params->CallbackParameter->firstName)) === '') {
             throw new Exception('System Error: firstName is mandatory!');
         }
         if (!isset($params->CallbackParameter->lastName) || ($lastName = trim($params->CallbackParameter->lastName)) === '') {
             throw new Exception('System Error: lastName is mandatory!');
         }
         if (!isset($params->CallbackParameter->userName) || ($userName = trim($params->CallbackParameter->userName)) === '') {
             throw new Exception('System Error: userName is mandatory!');
         }
         if (!isset($params->CallbackParameter->roleid) || !($role = Role::get($params->CallbackParameter->roleid)) instanceof Role) {
             throw new Exception('System Error: role is mandatory!');
         }
         $newpassword = trim($params->CallbackParameter->newpassword);
         if (!isset($params->CallbackParameter->userid) || !($userAccount = UserAccount::get($params->CallbackParameter->userid)) instanceof UserAccount) {
             $userAccount = new UserAccount();
             $person = new Person();
             if ($newpassword === '') {
                 throw new Exception('System Error: new password is mandatory!');
             }
             $newpassword = sha1($newpassword);
         } else {
             $person = $userAccount->getPerson();
             if ($newpassword === '') {
                 $newpassword = $userAccount->getPassword();
             } else {
                 $newpassword = sha1($newpassword);
             }
         }
         //double check whether the username has been used
         $users = UserAccount::getAllByCriteria('username=? and id!=?', array($userName, $userAccount->getId()), false, 1, 1);
         if (count($users) > 0) {
             throw new Exception('Username(=' . $userName . ') has been used by another user, please choose another one!');
         }
         $person->setFirstName($firstName)->setLastName($lastName)->save();
         $userAccount->setUserName($userName)->setPassword($newpassword)->setPerson($person)->save();
         $results = $userAccount->clearRoles()->addRole($role)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
開發者ID:larryu,項目名稱:magento-b2b,代碼行數:48,代碼來源:UsersController.php


注:本文中的UserAccount::getAllByCriteria方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。