Example #1
0
 def update_member_count(self):
     sql = '''update {} set member_count=(
              select count(*) from `mini_belong` where group_id=%s)
              where id = %s
           '''.format(self.__table__)
     params = (self.id, self.id)
     store.execute(sql, params)
     store.commit()
Example #2
0
 def update_member_count(self):
     sql = '''update {} set member_count=(
              select count(*) from `mini_belong` where group_id=%s)
              where id = %s
           '''.format(self.__table__)
     params = (self.id, self.id)
     store.execute(sql, params)
     store.commit()
Example #3
0
 def create(cls, blog_id, content, creator_id):
     sql = 'insert into {} (blog_id,content,creator_id) values(%s, %s, %s)'.format(cls.__table__)
     params = (blog_id, content, creator_id)
     id = store.execute(sql,params)
     store.commit()
     if id:
         blog = Blog.get(blog_id)
         blog.add_comment_count(1)
     return id
Example #4
0
 def create(cls, blog_id, content, creator_id):
     sql = 'insert into {} (blog_id,content,creator_id) values(%s, %s, %s)'.format(
         cls.__table__)
     params = (blog_id, content, creator_id)
     id = store.execute(sql, params)
     store.commit()
     if id:
         blog = Blog.get(blog_id)
         blog.add_comment_count(1)
     return id
Example #5
0
 def create(cls, name, intro, creator):
     sql = 'insert into {} (name,intro,creator_id) values(%s, %s, %s)'.format(cls.__table__)
     params = (name, intro, creator)
     id = store.execute(sql,params)
     store.commit()
     # add default belong
     if not id:
         return None
     sql = 'insert into `mini_belong` (user_id, group_id) values (%s, %s)'
     params = (creator, id)
     store.execute(sql, params)
     store.commit()
     return id
Example #6
0
 def create(cls, name, intro, creator):
     sql = 'insert into {} (name,intro,creator_id) values(%s, %s, %s)'.format(
         cls.__table__)
     params = (name, intro, creator)
     id = store.execute(sql, params)
     store.commit()
     # add default belong
     if not id:
         return None
     sql = 'insert into `mini_belong` (user_id, group_id) values (%s, %s)'
     params = (creator, id)
     store.execute(sql, params)
     store.commit()
     return id
Example #7
0
 def delete(self):
     sql = 'delete from {} where id=%s'.format(self.__table__)
     store.execute(sql, self.id)
     store.commit()
Example #8
0
 def create(cls, title, content, creator_id, group_id):
     sql = 'insert into {} (title,content,creator_id,group_id) values(%s, %s, %s, %s)'.format(cls.__table__)
     params = (title, content, creator_id, group_id)
     id = store.execute(sql,params)
     store.commit()
     return id
Example #9
0
 def add_comment_count(self, val):
     sql = 'update {} set comment_count=%s where id=%s'.format(self.__table__)
     params = (int(self.comment_count) + val, self.id)
     id = store.execute(sql,params)
     store.commit()
Example #10
0
 def delete_member(self, user_id):
     sql = 'delete from `mini_belong` where user_id=%s and group_id=%s'
     params = (user_id, self.id)
     store.execute(sql, params)
     store.commit()
Example #11
0
 def add_member(self, user_id):
     sql = 'insert into `mini_belong` (user_id, group_id) values (%s, %s)'
     params = (user_id, self.id)
     store.execute(sql, params)
     store.commit()
Example #12
0
 def delete(self):
     sql = 'delete from {} where id=%s'.format(self.__table__)
     store.execute(sql, self.id)
     store.commit()
     blog = Blog.get(self.blog_id)
     blog.add_comment_count(-1)
Example #13
0
 def delete(self):
     sql = 'delete from {} where id=%s'.format(self.__table__)
     store.execute(sql, self.id)
     store.commit()
     blog = Blog.get(self.blog_id)
     blog.add_comment_count(-1)
Example #14
0
 def delete_member(self, user_id):
     sql = 'delete from `mini_belong` where user_id=%s and group_id=%s'
     params = (user_id, self.id)
     store.execute(sql, params)
     store.commit()
Example #15
0
 def add_member(self, user_id):
     sql = 'insert into `mini_belong` (user_id, group_id) values (%s, %s)'
     params = (user_id, self.id)
     store.execute(sql, params)
     store.commit()