作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我有 3 个相关模型:
class Transaction
include DataMapper::Resource
property :id, Serial
property :volume, Float
property :deal_date, Date
belongs_to :buyer
belongs_to :seller
end
class Seller
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :transactions
end
class Buyer
include DataMapper::Resource
property :id, Serial
property :name, String, :length => 255, :index => true, :unique => true
has n, :transactions
end
我想在某些条件下查询交易:
x < volume < y
and
a < deal_date < b
and
( buyer.name like key_word OR seller.name like key_word )
如何使用 Datamapper 在两个 LIKE 之间创建 OR 条件?
最佳答案
简单查询Transaction
,但查询路径为buyer.name
和seller.name
。
Transaction.all('buyer.name.like' => keyword) | Transaction.all('seller.name.like' => keyword)
关于ruby - 如何在 LIKE 与 Datamapper 之间建立 OR 条件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11888343/
我是一名优秀的程序员,十分优秀!