简体   繁体   English

如何将sql server连接到我的Javascript游戏?

[英]How do I connect a sql server to my Javascript game?

I'm working on a project and I just need a holistic overview on how to go about it. 我正在开展一个项目,我只需要对如何进行整体概述。

I'm going to use HTML/CSS canvas to make the game. 我将使用HTML / CSS画布制作游戏。

However, the game involves visualization of large amounts of data that is best served in a database. 但是,游戏涉及在数据库中最佳服务的大量数据的可视化。 What I do not know how to do is: 我不知道该怎么做:

  1. Link my HTML/CSS game to a SQL database 将我的HTML / CSS游戏链接到SQL数据库
  2. Parse a text file to populate the database. 解析文本文件以填充数据库。

I don't have specific issues I just don't even know where to start? 我没有具体问题,我甚至不知道从哪里开始? Some people have said AJAX? 有人说AJAX? Others have said parse.com? 其他人说parse.com?

You have two options: 您有两种选择:

  • write a server-side application to serve data from a DB 编写服务器端应用程序以从DB提供数据
  • use client-side HTML5 storage (such as local storage, WebSQL, IndexedDB, etc) 使用客户端HTML5存储 (例如本地存储,WebSQL,IndexedDB等)

If you use the server implementation you will need AJAX to communicate with the server. 如果使用服务器实现,则需要AJAX与服务器通信。

To do this you will have toove beyond JavaScript and learn server side programming. 要做到这一点,你将超越JavaScript并学习服务器端编程。 The good news is there are tons of awesome server side languages that make building websites easy. 好消息是有很多令人敬畏的服务器端语言,使构建网站变得容易。

If you come from a javascript background, ruby would probably be an easy transition. 如果你来自javascript背景,ruby可能是一个简单的过渡。 I'd suggest Sinatra. 我建议Sinatra。

If you are using SQL server, c# and asp.net are great choices that are very well designed, thou c# is very different from JavaScript as a language. 如果你使用的是SQL服务器,那么c#和asp.net是很好的选择,设计得非常好,你可以把它作为一种语言与JavaScript非常不同。

Like python? 像蟒蛇? Web2py and Django are good. Web2py和Django都不错。

Then there is PHP and java... 然后有PHP和java ...

You would probably write an API in one of these server side languages, access it using Ajax to retrieve Jason and process it. 您可能会使用其中一种服务器端语言编写API,使用Ajax访问它以检索Jason并对其进行处理。

And don't bother with parse.com. 并且不要打扰parse.com。 write your own parser in the language of your choice. 用您选择的语言编写自己的解析器。 Its usually really easy, and instructive. 它通常很容易,也很有启发性。

I think you already know a language you can use. 我想你已经知道了一种可以使用的语言。 How about javascript? javascript怎么样? Of course a real serverside language like Java or PHP would be better - maybe as already told: ruby but why not try it with node.js: 当然,像Java或PHP这样真正的服务器端语言会更好 - 也许已经说过:ruby但是为什么不尝试使用node.js:

Node.js could be the first thing you may look at. Node.js可能是你可以看到的第一件事。 ( http://nodejs.org/ ) http://nodejs.org/

It's really nice & well documented - there is also a big question about node.js with mysql: MySQL with Node.js which also works fine. 它非常好并且有很好的文档记录 - 对于带有mysql的node.js也有一个很大的问题: 带有Node.js的MySQL也可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM