Apache cordova dengan mysql database

Make mobile app for website. That is, the desired output of articles, users, etc. DB is on the hosting. Own server is not present, so Node.JS does not roll. How do I connect to the database in order to pick up data, please tell me? I would be grateful for an adequate response.

Related questions

  • 5What is GitHub and why you need it?
  • 1How do I get the profiling results without the debug panel?
  • 2Webpack. The Url loader returns a url kosyachny, what's the problem?
  • 1As for Bitrix to see the logs of edits pages?
  • 4What log analyzer for nginx, apache, apache tomcat are using?
  • 2The problem with the software installed in the computer how to solve?
  • 1Why doesn't Paperclip?
  • 1To open a link in chrome when you connect headphones [tasker for Android]?

2 answers

benny43 answered on September 13th 19 at 21:55

Solution

Own server is not present, so Node.JS does not roll.

well, you have a website? So it is possible to create an API to the database.

rubye_Rodriguez answered on September 13th 19 at 21:57

Direct connection to the database from client applications is a very bad idea, anyone can watch anything in your database, and probably even to change something.
Write API.

Find more questions by tags ApacheApache CordovaMySQL

PhoneGap PHP MySQL Example

In this article, I would like to write an article about PhoneGap with PHP & MySQL.we’ll see how to perform CRUD [Create, Read, Update, Delete] operations with MySQL Database.

Step By Step Guide:

  • MySQL Database Creation
  • Writing PHP code for Serverside
  • Writing Jquery code for PhoneGap / Apache Cordova side

Dependencies: PHP, MySQL, JQuery

Learn More about PHP & MySQL //www.w3schools.com/php/php_mysql_intro.asp or //www.tutorialspoint.com/php/php_and_mysql.htm

Working with MySQL database

Let’s create a new table called course details where, we can store information about courses such as title, duration, and price.we also need to set primary key & auto increment for id

CREATE TABLE `course_details` [

`id` int[1] NOT NULL, 
`title` varchar[25] NOT NULL, 
`duration` varchar[50] NOT NULL, 
`price` varchar[10] NOT NULL

] ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; 

ALTER TABLE `course_details` ADD PRIMARY KEY [ `id` ]; 
ALTER TABLE `course_details` MODIFY `id` int[1] NOT NULL AUTO_INCREMENT;

After creating a new table, we need to create simple REST API

Working with PHP code

Let’s create a simple API [no security layer added] for fetching data from MySQL database & display as JSON.here we’re going to create multiple files for insert, delete, update operations. If you want you can merge all files into one single PHP file

Connecting Database Server [ db.php ]

This file allows you to connect your MySQL database


NOTE

header["Access-Control-Allow-Origin: *"]; use to allow cross domains

Insert data into MySQL database using PHP [ insert.php ]

This code will receive data from the mobile / PhoneGap Apache Cordova using POST method & It’ll insert data to MySQL, If it is successful it will return ok as output otherwise error as output

Bài mới nhất

Chủ Đề