if (sets.length == 1) {
dao.update(taskTimerExec.getTab(), Chain.make(sets[0].split("=")[0], sets[0].split("=")[1]),
Cnd.wrap(taskTimerExec.getWheres()));
} else if (sets.length == 2) {
dao.update(taskTimerExec.getTab(), Chain.make(sets[0].split("=")[0], sets[0].split("=")[1])
.add(sets[1].split("=")[0], sets[1].split("=")[1]), Cnd.wrap(taskTimerExec.getWheres()));
} else if (sets.length == 3) {
dao.update(taskTimerExec.getTab(),
Chain.make(sets[0].split("=")[0], sets[0].split("=")[1])
.add(sets[1].split("=")[0], sets[1].split("=")[1]).add(sets[2].split("=")[0],
sets[2].split("=")[1]),
Cnd.wrap(taskTimerExec.getWheres()));
} else if (sets.length == 4) {
dao.update(taskTimerExec.getTab(),
Chain.make(sets[0].split("=")[0], sets[0].split("=")[1])
.add(sets[1].split("=")[0], sets[1].split("=")[1])
.add(sets[2].split("=")[0], sets[2].split("=")[1]).add(sets[3].split("=")[0],
sets[3].split("=")[1]),
Cnd.wrap(taskTimerExec.getWheres()));
}
就是 taskTimerExec.getTab() 是表名 sets是 a=b,c=d要更新的字段taskTimerExec.getWheres()这个是 更新条件
我的意思就是 a=b,c=d 是不确定有几个的 更新的字段不确定
2 回复
你这个太简单了:
Chain chain = Chain.make(sets[0].split("=")[0], sets[0].split("=")[1]);
for(int i = 1; i < sets.length; i++){
String setStr = String.valueOf(sets.get(i));
chain = chain.add(setStr .split("=")[0], setStr .split("=")[1]);
}
dao.update(taskTimerExec.getTab(), chain, Cnd.wrap(taskTimerExec.getWheres()));
红包发到微信:13541087392
添加回复
请先登陆