Skip navigation
Currently Being Moderated

Help uploading data to database using a service

May 5, 2012 7:14 PM

I had Flex automatically create me a service to access a database I have on the web to do simple things like populate dropdownlists and it has been working great.  When you have Flex create a service, Flex automatically creates several PHP functions to do things like get all data in a table, to get all data by ID, to delete a record, to create a record, or to update a record.  So far, I have only been using functions that download data to ingest in Flex.  Now, I need to write data to the database and have run into a problem.  I don't know how to organize the data to upload to the database.

 

First, I tried creating an arraycollection as the parameter sent to the createProject PHP function, which is a function in the Project Service that writes a record to the project table:

 

var projectCollection:ArrayCollection = new ArrayCollection();
projectCollection.addItem({projNum: 1, custNum, 2, firstName: "John", lastName: "Doe"});
 
projectService.createProject(projectCollection);

 

 

 

This did not work, so I tried the same thing but put all the data in an object:

 

var projectCollection:Object = {projNum: 1, custNum, 2, firstName: "John", lastName: "Doe"};
 
projectService.createProject(projectCollection);

 

 

 

Unfortunately, this did not work either.  In both cases, Flex is saying that I am trying to  coerce a value of type mx.collections:ArrayCollection to an unrelated type valueObjects:Project.  Looking at this, it become apparent that when Flex creates a service, it creates valueObjects, and that I need to be sending a value object.  Sadly, I am not real familiar with valueObjects and do not know how to assign my tables values to the generated valueObjects.

 

Could someone please give me a heads up on how to organize my data into an appropriate valueObject to send data to my database?

 

Thanks!!!

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points