[英]Kohana ORM: How to query for a timestamp that's calculated based on a field in the DB
簡單表:
start_date TIMESTAMP
duration_days INT
用英語:我只希望沒有超過其duration
時間的行。
在SQL中:
SELECT * FROM MyTable WHERE now() < TIMESTAMPADD(DAY, duration_days, start_date);
如何在Kohana / ORM中做到這一點? 我需要檢索的許多行的持續時間都不相同。
只需使用where()
子句:
ORM::factory('MyTable')->where(DB::expr('now()'), '<', DB::expr('TIMESTAMPADD(DAY, duration_days, start_date)'))->find_all();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.