def serach_count(self, key): q = db.select(self.table).fields(db.expr('count(*)', 'total')).condition('status', 'published') _or = db.or_() _or.condition('slug', '%%%s%%' % key, 'LIKE').condition('title', '%%%s%%' % key, 'LIKE') q.condition(_or) return q.execute()[0][0]
def serach_count(self, key): q = db.select(self.table).fields(db.expr('count(*)', 'total')).condition( 'status', 'published') _or = db.or_() _or.condition('slug', '%%%s%%' % key, 'LIKE').condition('title', '%%%s%%' % key, 'LIKE') q.condition(_or) return q.execute()[0][0]
def count(self, status=None): q = db.select(self.table).fields(db.expr('COUNT(*)')) if status: q.condition('status', status) return q.execute()[0][0]
def category_count(self, category_id): return db.select(self.table).fields(db.expr( 'count(*)', 'total')).condition('category', category_id).condition( 'status', 'published').execute()[0][0]
def test_expr(self): from db import expr res = self.select.fields(expr('count(*)')).execute() self.assertEqual(res[0][0], 5) res = db.select('users').fields(expr('count(uid)', 'total')).execute() self.assertEqual(res[0][0], 5)
def spam_count(self, domain): return db.select(self.table).fields(db.expr('COUNT(*)')).condition( 'email', domain, 'LIKE').execute()[0][0]
def count(self): return db.select(self.table).fields( db.expr('COUNT(*)')).execute()[0][0]
def count_slug(self, slug): return db.select(self.table).fields(db.expr('COUNT(*)')).condition('slug', slug).execute()[0][0]
def count(self, status=None): q= db.select(self.table).fields(db.expr('COUNT(*)')) if status != 'all': q.condition('status', status) return q.execute()[0][0]
def category_count(self, category_id): return db.select(self.table).fields(db.expr('count(*)', 'total')).condition('category', category_id).condition('status', 'published').execute()[0][0]
def count(self): return db.select(self.table).fields(db.expr('COUNT(*)')).execute()[0][0]
def count(self, **kw): q = db.select(self.table).fields(db.expr('COUNT(*)')) if kw: for k, v in kw.iteritems(): q.condition(k, v) return q.execute()[0][0]
def spam_count(self, domain): return db.select(self.table).fields(db.expr('COUNT(*)')).condition('email', domain, 'LIKE').execute()[0][0]