我想用活动的android更新单行的多个单元格。 像这样的事情,
new Update(Question.class).set("UserAnswer ="+answerID,
"UserAnswerType = "+userAnswerType)
.where("QID = ?", questionID).execute();
但这会给我错误。还有其他办法吗?或者我错过了什么?
这是我的Question.class供参考
@Table(name = "Questions")
public class Question extends Model {
@Expose
@Column(name = "QID")
private Integer ID;
@Expose
@Column(name = "AnswerID")
private Integer AnswerID;
@Expose
@Column(name = "UserAnswer")
private Integer UserAnswer;
@Expose
@Column(name = "UserAnswerType")
private Integer UserAnswerType;
//Getter and setter methods for fields
public Question() {
// You have to call super in each constructor to create the table.
super();
}
}
答案 0 :(得分:2)
您可以执行以下操作。我已经在我的一个项目中完成了它并且工作正常。
String updateSet = " UserAnswer = ? ," +
" UserAnswerType = ? ";
new Update(Question.class)
.set(updateSet, answerID, userAnswerType)
.where(" QID = ? ", questionID)
.execute();
对于任意数量的列,遵循类似的模式将起作用。如果您的表格中有Boolean
个字段,this issue可以为您提供帮助。
答案 1 :(得分:0)
我们可以这样做。
bullet
答案 2 :(得分:-1)
String x="sent = 1,file = "+n.getString("file");
new Update(Messages.class)
.set(x)
.where("id = ?", lid)
.execute();