Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

multi parameter in ActiveAndroid

I am using ActiveAndroid as ORM system in my project and i use this line of code for Query over database

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

but it fetch 0 row as result. i am sure that i have such row in database.

like image 799
Navid_pdp11 Avatar asked Sep 21 '26 15:09

Navid_pdp11


2 Answers

Another way is to use several where clause to execute multiparameter query:

List<Chats> s = new Select()
            .from(Chats.class)
            .where(col_conversation + " = ?",conversation.getId())
            .where(col_sender + " = ?", sender.getId())
            .where(body + " = ?", body)
            .execute();
like image 162
romtsn Avatar answered Sep 24 '26 07:09

romtsn


you most pass no parameters and change your select query to below :

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

                .execute();
like image 24
MohammadReza Vahedi Avatar answered Sep 24 '26 06:09

MohammadReza Vahedi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!