3: def add_category_to_object(category, object)
4: if !find(:first, :conditions => {object_id_column => object, :category_id => category} )
5: connection.execute("insert into #{table_name} (category_id, #{object_id_column}) values(#{category.id}, #{object.id})")
6:
7: c = category.parent
8: while !c.nil? && !self.find(:first, :conditions => {object_id_column => object, :category_id => c})
9: connection.execute("insert into #{table_name} (category_id, #{object_id_column}, virtual) values(#{c.id}, #{object.id}, 1>0)")
10: c = c.parent
11: end
12: else
13: connection.execute "update #{table_name} set virtual = (1!=1) where #{object_id_column} = #{object.id} and category_id = #{category.id}"
14: end
15: end