It might help to read this:
http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/
Basically no database administrator or IT Manager will want their MySQL databases exposed to a public network. So there has to be something sitting between the Internet and the database to restrict queries to what is allowed filter input, etc. It’s a standard rule in doing any server side programming to always assume the data/commands you receive are attempts to hack your system. You would NEVER let an app (be it a mobile device or a web page) ever write SQL directly to your database. If you did, someone you don’t control could send a lovely “DROP TABLE” command to you.
In many cases, that intermediary is an API or Application Programming Interface. You get very specific and restrictive things you can do, like “Register a user”, “login a user”, “fetch a list of items” to sell. The API takes values you send, scrubs it to make sure you’re not sending in SQL, etc. It contacts the database on a non-public port, gathers the output of the database query and then returns it to you in a standard format that your app can digest. Frequently, this intermediate code will be written in in a server side scripting language like PHP, but can be done with Ruby, Python or other similar languages.
The script will typically output the data to you in either XML or JSON. For Corona, JSON is the better format as it maps to Lua Tables quite well. Many of these API’s will run either using the SOAP or the REST protocol for authenticating data, but in very simple terms, you do standard HTTP requests like GET and POST to fetch data from the server or send data to the server.
In web terms, this would be a <form> tag and when the user clicks the submit form, it calls the webserver passes some data to it, gets the result back . For Corona, there is a specific API call called “network.request()” where you give it the URL of the web service you are hitting, if it’s a GET or POST request, a list of parameters to pass to the form and a function in your app responsible for the data that is returned.
Now if your server API can spit out JSON data (super easy with PHP), then you take the data from the server in your function and run a json.decode() call on the data and store the result in a Lua table and you have results. The blog post above basically covers this in detail.
[import]uid: 19626 topic_id: 31187 reply_id: 124737[/import]