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()
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
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
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
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
def delete(self): sql = 'delete from {} where id=%s'.format(self.__table__) store.execute(sql, self.id) store.commit()
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
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()
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()
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()
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)