Mysql in Ionic


#1

How can I use MySQL database in ionic? Can I use it with ‘www’ folder included in the project?


#2

No. You will have to write a web application that provides a API (best REST API) to your Ionic app.


#3

How can I insert data in the MySQL database using Ionic app?


#4

You can’t. you need a server to deal with mysql.


#5

Can you please help me with this?


#6

you cannot directly talk with MySQL in ionic, the recommended way is to use API.

think like this:
Server (has MySQL Database) <-------> REST API <------------> ionic app using http request/response

  1. Server, anything you want to call it,with mysql server inside of it.
  2. build a rest api inside your server, example (lumen/laravel/ or whatever you want for a rest api).
  3. make an ionic provider in your app project, use http
  4. you can use the result of that http response, whether you want it to display on the page or store it on a local storage on your device like sqlite.

#7

Can you give me some resources for this?


#8

I dont know your preferences, but here one for lumen or laravel

for using http response/request and providers in ionic 2 please check this

hope it helps you.


#9

Thanks for these resources. I want to send data from ionic app to the server. Is there any way to do so?