是否可以在没有 php 代码的情况下使用 angular js 连接 mysql db
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31830232/
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
is it possible to connect mysql db using angular js without php code
提问by Anandha Mariappan A
Is it possible to connect MySql db using angularjs without PHP code? based on client side scripting we can't connect MySql db. Is it any other way to connection?
是否可以在没有 PHP 代码的情况下使用 angularjs 连接 MySql 数据库?基于客户端脚本,我们无法连接 MySql 数据库。有没有其他的连接方式?
回答by Nemanja Milosavljevic
If you wish to use just Angular for accessing your database, then discard PHP all together, and switch to something like Firebase. It will allow you to do almost everything from your Angular application (not saying that you should do it that way, but you could).
如果您只想使用 Angular 来访问您的数据库,那么就一起丢弃 PHP,并切换到Firebase 之类的东西。它将允许你从你的 Angular 应用程序中做几乎所有的事情(不是说你应该那样做,但你可以)。
AngularJS is a Front-end framework, and it should be used in combination with some server side language: Java/C#/NodeJS/PHP...
AngularJS 是一个前端框架,需要结合一些服务端语言使用:Java/C#/NodeJS/PHP...
But to answer your question directly: No, you can't access MySQL from Angular.
但是直接回答你的问题:不,你不能从 Angular 访问 MySQL。
回答by Vidyadhar
No, you cant connect MySql DB(Backend) with any client side javascript libraries so cant connect Backend DB with angularjs.
不,您无法将 MySql DB(后端)与任何客户端 javascript 库连接,因此无法将后端 DB 与 angularjs 连接。
You can pick any server side programming language(not only php) to access MySql DB and write webservice interface to pass data from backend to your client.
您可以选择任何服务器端编程语言(不仅是 php)来访问 MySql DB 并编写 web 服务接口以将数据从后端传递到您的客户端。
If you are willing to have a db at client side which can be accessed with javascript(even angularjs) and no need to use any server side programming language then can go with below methods:
如果您愿意在客户端拥有一个可以使用 javascript(甚至 angularjs)访问的数据库,并且不需要使用任何服务器端编程语言,那么可以使用以下方法:
Indexed Database
Web SQL
localStorage
回答by Nandabasu M
As of now we can't connect to our DB through client script. But there is alternate solution to store your data in google's FIREBASE https://www.firebase.com/tutorial/#session/omykpz5lraw.
截至目前,我们无法通过客户端脚本连接到我们的数据库。但是有另一种解决方案可以将您的数据存储在谷歌的 FIREBASE https://www.firebase.com/tutorial/#session/omykpz5lraw 中。
This can be done by using nodejs as server to connect to ur database(I have done it using MangoDB). Since Angular js follows MVC architecture, you can use it as service layer too.
这可以通过使用 nodejs 作为服务器连接到你的数据库来完成(我已经使用 MangoDB 完成了)。由于 Angular js 遵循 MVC 架构,因此您也可以将其用作服务层。