예제 #1
0
파일: post.py 프로젝트: lf8289/white
 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
파일: post.py 프로젝트: zgwdg/white
 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
파일: post.py 프로젝트: lf8289/white
 def search(self, key, page=1, perpage=10):
     q = db.select(self.table).fields('title', 'slug', 'description', 'html', 'css', 'js',
                                      'category', 'status', 'allow_comment', 'author', 'updated', 'created', 'pid')
     _or = db.or_()
     _or.condition('slug', '%%%s%%' % key, 'LIKE').condition('title', '%%%s%%' % key, 'LIKE')
     q.condition(_or)
     results = (q.condition('status', 'published').limit(perpage).offset((page - 1) * perpage)
                 .order_by('created', 'DESC').execute())
     return [self.load(data, self.model) for data in results]
예제 #4
0
파일: post.py 프로젝트: zgwdg/white
 def search(self, key, page=1, perpage=10):
     q = db.select(self.table).fields('title', 'slug', 'description',
                                      'html', 'css', 'js', 'category',
                                      'status', 'allow_comment', 'author',
                                      'updated', 'created', 'pid')
     _or = db.or_()
     _or.condition('slug', '%%%s%%' % key,
                   'LIKE').condition('title', '%%%s%%' % key, 'LIKE')
     q.condition(_or)
     results = (q.condition('status', 'published').limit(perpage).offset(
         (page - 1) * perpage).order_by('created', 'DESC').execute())
     return [self.load(data, self.model) for data in results]