Search in sources :

Example 16 with SelectStatement

use of com.orm.androrm.statement.SelectStatement in project androrm by androrm.

the class QuerySet method getCount.

private int getCount(SelectStatement query) {
    SelectStatement countQuery = new SelectStatement();
    countQuery.from(query).count();
    Cursor c = getCursor(countQuery);
    int count = 0;
    if (c.moveToFirst()) {
        count = c.getInt(c.getColumnIndexOrThrow(Model.COUNT));
    }
    closeConnection(c);
    return count;
}
Also used : SelectStatement(com.orm.androrm.statement.SelectStatement) Cursor(android.database.Cursor)

Aggregations

SelectStatement (com.orm.androrm.statement.SelectStatement)16 JoinStatement (com.orm.androrm.statement.JoinStatement)8 Statement (com.orm.androrm.statement.Statement)4 InStatement (com.orm.androrm.statement.InStatement)3 Cursor (android.database.Cursor)2 Relation (com.orm.androrm.field.Relation)2 Where (com.orm.androrm.Where)1 ForeignKeyField (com.orm.androrm.field.ForeignKeyField)1 ManyToManyField (com.orm.androrm.field.ManyToManyField)1 OneToManyField (com.orm.androrm.field.OneToManyField)1 ArrayList (java.util.ArrayList)1