Javascript和数据库连接 [英] Javascript and Database Connectivity

查看:89
本文介绍了Javascript和数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

javascript是否可以直接访问数据库?由于这是一个安全问题,我觉得我的问题很夸张。

Is it possible for javascript to access a database directly? I feel my question is rhetorical owing to the fact that this is a security issue. But is it possible anyway?

推荐答案

有可能!

具有新的html5功能,js可以通过WebSql连接。
a实时示例: http://html5demos.com/database

语法类似于所有其他sql包装程序:

It is possible!
with the new html5 feature, js can connect through WebSql. a live example : http://html5demos.com/database
the syntax is similar to all the other sql wrappers :

var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
db.transaction(function (tx) {
    tx.executeSql('CREATE TABLE foo (id unique, text)');
});    

Chrome,Safari和Opera当前支持它,这是一个教程: http://html5doctor.com/introducing-web-sql-databases/

it is currently supported by chrome, safari and opera
here's a tutorial : http://html5doctor.com/introducing-web-sql-databases/

这篇关于Javascript和数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆