0 Replies Latest reply on Dec 9, 2009 4:36 AM by radekdymacz

    Saving and updating ArrayCollection from SOAP request

    radekdymacz

      Hi

      I've got problem saving ArrayCollection from soap response to mysql database Its all fine if I want to save fresh ArrayCollection I just addAll to

      fill request ArrayCollection on Customer database table but if i want to update existing results in database with fresh data from SOAP ArrayCollection

      do I have to iterate trough each array element and update it or is there a better way to do it ? What if   Customer doesn't exist in database I need to catch that and create it by addItem to fill request ArrayCollection on Customer database table ? I apreciate any help I'm struggling with that for some time now

      Ive tried assigning bonding  whole ArrayCollection from SOAP to ArrayCollection from database fill and it doest seem to work (?)

      This is code how i'm doing it now

       

      for(var i:int = 0; i <    getAccountListResult.lastResult.length;i++)
              {
                   var not_exist:Boolean = true;
                  for(var n:int = 0 ; n < customersDB.length;n++)
                  {
                       not_exist = true;
                      {
                      if (customersDB[n].accountId == getAccountListResult.lastResult[i].accountId)
                      {   
                         
                          customersDB[n] = getAccountListResult.lastResult[i] as Customer;
                          not_exist = false;
                      }
                      }
                  }
                  if (not_exist)
                  {
                      //customersDB[n].addItem(getAccountListResult.lastResult[i]);
                     
                  }
                     
                 
              }
                 
             
              customerService.serviceControl.commit();