Rails系列教程(5):Active Records

上一篇 / 下一篇  2008-02-02 15:54:00 / 个人分类:RoR

Active Records : 被应用于ORM layer


ORM model : tables map to classes, rows to objects, and columns to object attributes
还是要强调一下,a row maps a object, a table maps a class, a column maps a attribute

 

Ex:

require 'active_record'

class Order < ActiveRecord::Base
end

# work on business logic

order = Order.find(1)    # fetch the order with an id of 1
order.discount = 0.5
order.save

 

很显然,这样的实现很直观,不需要考虑到内部如何连接数据库,如何使用SQL语句,一切都变得高效,快速(alige)


TAG: RoR

 

评分:0

我来说两句

我的栏目

日历

« 2024-05-01  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 22791
  • 日志数: 47
  • 建立时间: 2008-01-29
  • 更新时间: 2008-02-02

RSS订阅

Open Toolbar