ActiveAndroid 中的多参数

multi parameter in ActiveAndroid

我在我的项目中使用 ActiveAndroid 作为 ORM 系统,我使用这行代码对数据库进行查询

 List<Chats> s = new Select()
                .from(Chats.class)
                .where(col_conversation + " = ?  and " + col_sender + " = ? and " + col_body + " = ?",conversation.getId(),sender.getId(),body)    .execute();

但结果是获取了 0 行。我确定我在数据库中有这样的行。

您最常不传递任何参数并将您的 select 查询更改为以下内容:

List<Chats> s = new Select()
                .from(Chats.class)
                .where(col_conversation + " = " + conversation.getId() + " and " + col_sender + " = " + sender.getId() + " and " + col_body + " = '" + body + "'")

                .execute();

另一种方法是使用多个where子句来执行多参数查询:

List<Chats> s = new Select()
            .from(Chats.class)
            .where(col_conversation + " = ?",conversation.getId())
            .where(col_sender + " = ?", sender.getId())
            .where(body + " = ?", body)
            .execute();