javascript 如何在phonegap中连接mysql数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6704371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 21:35:56  来源:igfitidea点击:

How to connect to mysql database in phonegap

javascriptmysqldatabasecordova

提问by sam

Can anyone show me an example of how to connect to mysql database in phonegap or if its even possible ?

任何人都可以向我展示如何在 phonegap 中连接到 mysql 数据库的示例,或者甚至可能吗?

采纳答案by carok

I agree with cgwyllie you should write a webservice which will act as an API to your database with methods returning JSON (or XML).

我同意 cgwyllie 的观点,您应该编写一个 Web 服务,该服务将充当您的数据库的 API,并使用返回 JSON(或 XML)的方法。

The webservice methods can then be called from your PhoneGap project (I would recommend having a look at the jquery ajax api http://api.jquery.com/jQuery.ajax/).

然后可以从您的 PhoneGap 项目调用 webservice 方法(我建议查看 jquery ajax api http://api.jquery.com/jQuery.ajax/)。

I would just write the webservice in PHP or whatever language you are familiar with.

我只会用 PHP 或您熟悉的任何语言编写网络服务。