示例#1
0
 public function updateUser(User $user)
 {
     $updateArray = array('username' => $user->getUsername() ?: null, 'role' => $user->getRole() ?: null, 'salt' => $user->getSalt() ?: null, 'password' => $user->getPassword() ?: null, 'fullName' => $user->getFullName() ?: null, 'gender' => $user->getGender() ?: null, 'birthdate' => $user->getBirthdate() ?: null, 'email' => $user->getEmail() ?: null, 'mobile' => $user->getMobile() ?: null, 'cityId' => (int) $user->getCityId() ?: null, 'districtId' => (int) $user->getDistrictId() ?: null, 'address' => $user->getAddress() ?: null, 'rememberMe' => $user->getRememberMe() ?: null, 'lastAccess' => $user->getLastAccess() ?: null, 'activeKey' => $user->getActiveKey() ?: null, 'resetKey' => $user->getResetKey() ?: null, 'active' => $user->getActive(), 'registeredDate' => $user->getRegisteredDate() ?: null, 'facebook' => $user->getFacebook() ?: null, 'description' => $user->getDescription() ?: null, 'locked' => $user->getLocked() ?: null);
     $updateArray = array_filter($updateArray, 'strlen');
     $updateArray = array_filter($updateArray);
     $update = $this->getDbSql()->update(self::TABLE_NAME);
     if ($user->getId()) {
         $update->where(array('id' => $user->getId()));
     }
     $update->set($updateArray);
     $query = $this->getDbSql()->buildSqlString($update);
     $result = $this->getDbAdapter()->query($query, Adapter::QUERY_MODE_EXECUTE);
     return $result;
 }