Changeset 8367
- Timestamp:
- 12/10/07 09:12:18 (9 months ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r8362 r8367 1 1 *SVN* 2 2 3 * Document Active Record exceptions. #10444[Michael Klishin]3 * Documentation: Active Record exceptions, destroy_all and delete_all. #10444, #10447 [Michael Klishin] 4 4 5 5 trunk/activerecord/lib/active_record/base.rb
r8362 r8367 679 679 end 680 680 681 # Destroys the objects for all the records that match the +conditions+ by instantiating each object and calling 682 # the destroy method. Example: 681 # Destroys the records matching +conditions+ by instantiating each record and calling the destroy method. 682 # This means at least 2*N database queries to destroy N records, so avoid destroy_all if you are deleting 683 # many records. If you want to simply delete records without worrying about dependent associations or 684 # callbacks, use the much faster +delete_all+ method instead. 685 # 686 # ==== Options 687 # 688 # +conditions+ Conditions are specified the same way as with +find+ method. 689 # 690 # ==== Example 691 # 683 692 # Person.destroy_all "last_login < '2004-04-04'" 693 # 694 # This loads and destroys each person one by one, including its dependent associations and before_ and 695 # after_destroy callbacks. 684 696 def destroy_all(conditions = nil) 685 697 find(:all, :conditions => conditions).each { |object| object.destroy } 686 698 end 687 699 688 # Deletes all the records that match the +conditions+ without instantiating the objects first (and hence not 689 # calling the destroy method). Example: 700 # Deletes the records matching +conditions+ without instantiating the records first, and hence not 701 # calling the destroy method and invoking callbacks. This is a single SQL query, much more efficient 702 # than destroy_all. 703 # 704 # ==== Options 705 # 706 # +conditions+ Conditions are specified the same way as with +find+ method. 707 # 708 # ==== Example 709 # 690 710 # Post.delete_all "person_id = 5 AND (category = 'Something' OR category = 'Else')" 711 # 712 # This deletes the affected posts all at once with a single DELETE query. If you need to destroy dependent 713 # associations or call your before_ or after_destroy callbacks, use the +destroy_all+ method instead. 691 714 def delete_all(conditions = nil) 692 715 sql = "DELETE FROM #{quoted_table_name} "