10. Hey there folks-
I'm happy to announce the first useable release of my new pocket-
Merb is a mongrel handler with
framework Merb.
built in controller and view templating with
erb. It has a nice routing system similar to rails but much simpler.
It uses some of the code from the camping handler and the rails
handler and then some of its own secret sauce
to form imho a nice fast little framework.
-- Ezra Zygmuntowicz, 10-2006
Thursday, February 5, 2009
32. SELECT * FROM persons WHERE country = 'NL'
Thursday, February 5, 2009
33. SELECT * FROM persons WHERE country = 'NL'
AR: Person.find(:all, :conditions => [quot;country = ?quot;, quot;NLquot;])
Thursday, February 5, 2009
34. SELECT * FROM persons WHERE country = 'NL'
AR: Person.find(:all, :conditions => [quot;country = ?quot;, quot;NLquot;])
DM: Person.all(:country => quot;NLquot;)
Thursday, February 5, 2009
35. SELECT * FROM persons WHERE age BETWEEN 18
AND 21 ORDER BY AGE DESC
Thursday, February 5, 2009
36. SELECT * FROM persons WHERE age BETWEEN 18
AND 21 ORDER BY AGE DESC
AR: Person.find(:all, :conditions => [quot;age BETWEEN ? AND ?quot;, 18,
21], :order => quot;age DESCquot;) # => :( SQL fragments!
Thursday, February 5, 2009
37. SELECT * FROM persons WHERE age BETWEEN 18
AND 21 ORDER BY AGE DESC
AR: Person.find(:all, :conditions => [quot;age BETWEEN ? AND ?quot;, 18,
21], :order => quot;age DESCquot;) # => :( SQL fragments!
DM: Person.all(:age.gt => 18, :age.lt => 21, :order => [:age.desc])
Thursday, February 5, 2009
38. Nice: “strategic eager loading”
100 zoos; 250 exhibits
zoos = Zoo.all
zoos.each do |zoo|
zoo.exhibits.each do |exhibit|
puts quot;Zoo: #{zoo.name}, Exhibit: #{exhibit.name}quot;
end
end
Queries
ActiveRecord
DataMapper
Thursday, February 5, 2009
39. Nice: “strategic eager loading”
100 zoos; 250 exhibits
zoos = Zoo.all
zoos.each do |zoo|
zoo.exhibits.each do |exhibit|
puts quot;Zoo: #{zoo.name}, Exhibit: #{exhibit.name}quot;
end
end
Queries
101
ActiveRecord
DataMapper
Thursday, February 5, 2009
40. Nice: “strategic eager loading”
100 zoos; 250 exhibits
zoos = Zoo.all
zoos.each do |zoo|
zoo.exhibits.each do |exhibit|
puts quot;Zoo: #{zoo.name}, Exhibit: #{exhibit.name}quot;
end
end
Queries
101
ActiveRecord
2
DataMapper
Thursday, February 5, 2009
41. Associations
class Zoo
include DataMapper::Resource
class Zoo < ActiveRecord::Base
belongs_to :owner belongs_to :owner
has 1, :cafetaria has_one :cafetaria
has n, :animals has_many :animals
has n, :donors, :through => Resource has_and_belongs_to_many :donors
has n, :zookeepers, :through => :agencies has_many :zookeepers, :through => :agencies
end end
Thursday, February 5, 2009