js里执行mysql锁_javascript – 使用JS执行MySQL查询及其涉及的安全问题

本文介绍了一种简化Web2.0 JavaScript应用开发的方法,避免繁琐的CRUD和数据绑定。通过使用单一数据库类来封装多个数据库表,并用一个驱动脚本连接前端和后端,再配合前端包装类,可以轻松访问所有所需表格。示例代码展示了如何更新作者表,实现了在不手动编写大量底层代码的情况下,高效地进行数据交互。
摘要由CSDN通过智能技术生成

Introducing easy JavaScript data access

So you want to rapidly prototype a really cool Web 2.0 JavaScript application, but you don’t want to spend all your time writing the wiring code to get to the database? Traditionally, to get data all the way from the database to the front end, you need to write a class for each table in the database with all the create, read, update, and delete (CRUD) methods. Then you need to put some marshalling code atop that to provide an access layer to the front end. Then you put JavaScript libraries on top of that to access the back end. What a pain!

This文章介绍了一种替代方法,在该方法中,您使用单个数据库类来包装多个数据库表.单个驱动程序脚本将前端连接到后端,前端的另一个包装类使您可以访问所需的所有表.

实施例/使用

// Sample functions to update authors

function updateAuthorsTable() {

dbw.getAll( function(data) {

$('#authors').html('

IDAuthor
');

$(data).each( function( ind, author ) {

$('#authors tr:last').after('

'+author.id+''+author.name+'');

});

});

}

$(document).ready(function() {

dbw = new DbWrapper();

dbw.table = 'authors';

updateAuthorsTable();

$('#addbutton').click( function() {

dbw.insertObject( { name: $('#authorname').val() },

function(data) {

updateAuthorsTable();

});

});

});

我认为这正是你要找的.这样您就不必自己构建它.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值