예제 #1
0
파일: mapper.py 프로젝트: chenjayway/Zephyr
 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]
예제 #2
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]
예제 #3
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]
예제 #4
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]
예제 #5
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)
예제 #6
0
 def spam_count(self, domain):
     return db.select(self.table).fields(db.expr('COUNT(*)')).condition(
         'email', domain, 'LIKE').execute()[0][0]
예제 #7
0
 def count(self):
     return db.select(self.table).fields(
         db.expr('COUNT(*)')).execute()[0][0]
예제 #8
0
 def count_slug(self, slug):
     return db.select(self.table).fields(db.expr('COUNT(*)')).condition('slug', slug).execute()[0][0]
예제 #9
0
파일: mapper.py 프로젝트: chenjayway/Zephyr
 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]
예제 #10
0
파일: orm.py 프로젝트: hilliate/dbpy
 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]
예제 #11
0
파일: orm.py 프로젝트: hilliate/dbpy
 def count(self):
     return db.select(self.table).fields(db.expr('COUNT(*)')).execute()[0][0]
예제 #12
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]
예제 #13
0
파일: pymysqlt.py 프로젝트: duruyi/dbpy
 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)
예제 #14
0
파일: mapper.py 프로젝트: chenjayway/Zephyr
 def spam_count(self, domain):
     return db.select(self.table).fields(db.expr('COUNT(*)')).condition('email', domain, 'LIKE').execute()[0][0]