Simple table:
简单表:
start_date TIMESTAMP
duration_days INT
In English: I simply want the rows which have not passed their duration
period.
用英语:我只想要那些没有超过持续时间的行。
In SQL:
在SQL中:
SELECT * FROM MyTable WHERE now() < TIMESTAMPADD(DAY, duration_days, start_date);
How can I do this in Kohana/ORM? The duration is different for each of many rows I need to retrieve.
我怎样才能在Kohana / ORM中做到这一点?我需要检索的许多行中的每一行的持续时间都不同。
1 个解决方案
#1
1
Simply use a where()
clause:
只需使用where()子句:
ORM::factory('MyTable')->where(DB::expr('now()'), '<', DB::expr('TIMESTAMPADD(DAY, duration_days, start_date)'))->find_all();
#1
1
Simply use a where()
clause:
只需使用where()子句:
ORM::factory('MyTable')->where(DB::expr('now()'), '<', DB::expr('TIMESTAMPADD(DAY, duration_days, start_date)'))->find_all();