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 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]
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]