Exemple #1
0
 private function loadIntoDb()
 {
     $users = new USVN_Db_Table_Users();
     $users->getAdapter()->beginTransaction();
     foreach (array_keys($this->_users_password) as $user) {
         $data['users_login'] = $user;
         $data['users_password'] = $this->_users_password[$user];
         $where = $users->getAdapter()->quoteInto('users_login = ?', $user);
         $user_row = $users->fetchRow($where);
         try {
             if ($user_row === null) {
                 $users->insert($data);
             } else {
                 $users->update($data, $where);
             }
         } catch (Exception $e) {
             $users->getAdapter()->rollBack();
             throw new USVN_Exception(T_("Can't add users %s. Import cancel."), $user);
         }
     }
     $users->getAdapter()->commit();
 }