/*查询*/
select:function(tableName,callback,where,field){
field=field ? field : '*';
var sql="select "+field+" from "+this.C.DB_PRE+tableName;
if(where){
sql+=" where "+where;
}
this.db.query(sql,callback);
}
添加记录
/*添加*/
add:function(tableName,tableData,callback){
var sql="insert into "+this.C.DB_PRE+tableName;
var clumn='';
var value='';
for(var key in tableData){
clumn+=","+key;
value+=",'"+tableData[key]+"'";
}
clumns="("+clumn.substr(1)+")";
values="("+value.substr(1)+")";
sql=sql+clumns+"values"+values;
console.log(sql);
this.db.query(sql,callback);
}
修改记录
/*修改*/
update:function(tableName,tableData,where,callback){
var sql="update "+this.C.DB_PRE+tableName+" set ";
var clumns="";
for(var key in tableData){
clumns+=","+key+"='"+tableData[key]+"'";
}
clumns=clumns.substr(1);
sql+=clumns+" where "+where;
console.log(sql);
this.db.query(sql,callback);
}
删除记录
/*删除*/
delete:function(tableName,where,callback){
var sql="delete from "+this.C.DB_PRE+tableName+" where "+where;
console.log(sql);
this.db.query(sql,callback);
}