[Dbix-class] Removing rows older than a given number of minutes
...
Octavian Rasnita
octavian at fcc.ro
Sun Jan 24 07:44:08 GMT 2010
From: "Rob Kinyon" <rob.kinyon at gmail.com>
> On Sat, Jan 23, 2010 at 16:28, Kiffin Gish <kiffin.gish at planet.nl> wrote:
>> I want to delete all rows with a given state which have not been
>> modified for a given time in seconds.
>>
>> my @rows = rs->search({ state => $state }, { last_modified => ??? });
>> $_->delete for (@rows);
>>
>> How can I best do this?
>
> $rs->search({
> state => $state,
> last_modified => [ "< TIMEDIFF( NOW(), ? SECONDS", $seconds ],
> })->delete_all;
>
> Standard SQL::Abstract stuff, described in both the DBIC cookbook and
> the SQL::Abstract docs.
Is the following SQL
< TIMEDIFF( NOW(), ? SECONDS
a standard SQL code supported by more databases?
Until now I was using SQL codes like
< now() - interval ? second
but I am not sure if the keyword "interval" is used in other databases than
MySQL.
Thanks.
Octavian
More information about the DBIx-Class
mailing list