Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
简单表:
start_date TIMESTAMP duration_days INT
In English: 我只想要那些没有经过他们的duration时期的行。
duration
在 SQL 中:
SELECT * FROM MyTable WHERE now() < TIMESTAMPADD(DAY, duration_days, start_date);
我如何在 Kohana/ORM 中做到这一点?对于我需要检索的许多行中的每一行,持续时间都不同。
只需使用一个where()子句:
where()
ORM::factory('MyTable')->where(DB::expr('now()'), '<', DB::expr('TIMESTAMPADD(DAY, duration_days, start_date)'))->find_all();