Corona SDK and SQL database

I’m not new to Corona SDK or Lua, but I do have a question regarding a new avenue I’m taking. I’m creating a SQL database for my place of employment. I want my Corona app to get information from the SQL database. I’m not asking for code, but some general guidance on how this concept works. Should there be a medium between the database and my app? Can I connect to the database with the network.request command?

Yes, you need a go-between Corona and the database.  Technically speaking, if your database is something like MySQL then there is generally an open port that if you can authenticate to it, you do direct DB commands, though in many cases a reasonable company would hide this open port on a protected internal network and require you to use a controller app in-between.  A common way to do this is to write specific API functions in something like PHP where might have a single PHP script that only fetches addresses from the database based on a name.  

I did a tutorial while back that covers this:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

It’s a simple login service, but it can be adapted for other things.

Rob

Thanks a lot Rob. This isn’t the first time you’ve helped me. I have my data base set up and I’m ready for my app to communicate with the server side PHP script. However, I’m not quite sure about the DNS. Can corona SDK use the network API and simply reference my IP, or do I need a domain name assigned? I’m not sure if that’s synonymous with a DSN.

I guess a more basic rendering of my question is, “how can corona SDK communicate with my server, which my PHP file and database are on?” You don’t have to go into extreme detail, but could you point me in the right direction?

It’s done with network.request() – https://docs.coronalabs.com/api/library/network/request.html

See these two tutorials:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

https://coronalabs.com/blog/2015/06/02/tutorial-connecting-to-restful-api-services/

Rob

Yes, you need a go-between Corona and the database.  Technically speaking, if your database is something like MySQL then there is generally an open port that if you can authenticate to it, you do direct DB commands, though in many cases a reasonable company would hide this open port on a protected internal network and require you to use a controller app in-between.  A common way to do this is to write specific API functions in something like PHP where might have a single PHP script that only fetches addresses from the database based on a name.  

I did a tutorial while back that covers this:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

It’s a simple login service, but it can be adapted for other things.

Rob

Thanks a lot Rob. This isn’t the first time you’ve helped me. I have my data base set up and I’m ready for my app to communicate with the server side PHP script. However, I’m not quite sure about the DNS. Can corona SDK use the network API and simply reference my IP, or do I need a domain name assigned? I’m not sure if that’s synonymous with a DSN.

I guess a more basic rendering of my question is, “how can corona SDK communicate with my server, which my PHP file and database are on?” You don’t have to go into extreme detail, but could you point me in the right direction?

It’s done with network.request() – https://docs.coronalabs.com/api/library/network/request.html

See these two tutorials:

http://omnigeek.robmiracle.com/2012/04/15/using-corona-sdk-with-rest-api-services/

https://coronalabs.com/blog/2015/06/02/tutorial-connecting-to-restful-api-services/

Rob