Changeset 4645
- Timestamp:
- 08/01/06 03:35:04 (2 years ago)
- Files:
-
- trunk/activerecord/lib/active_record/base.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/lib/active_record/base.rb
r4635 r4645 1708 1708 def create_or_update 1709 1709 if new_record? then create else update end 1710 true 1710 1711 end 1711 1712 1712 1713 # Updates the associated record with values matching those of the instance attributes. 1714 # Returns the number of affected rows. 1713 1715 def update 1714 1716 connection.update( … … 1718 1720 "#{self.class.name} Update" 1719 1721 ) 1720 1721 return true 1722 end 1723 1724 # Creates a new record with values matching those of the instance attributes. 1722 end 1723 1724 # Creates a record with values matching those of the instance attributes 1725 # and returns its id. 1725 1726 def create 1726 1727 if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name) 1727 1728 self.id = connection.next_sequence_value(self.class.sequence_name) 1728 1729 end 1729 1730 1730 1731 self.id = connection.insert( 1731 1732 "INSERT INTO #{self.class.table_name} " + … … 1737 1738 1738 1739 @new_record = false 1739 1740 return true 1740 id 1741 1741 end 1742 1742