From: "Rob Kinyon" <rob.kin...@gmail.com>

On Sat, Jan 23, 2010 at 16:28, Kiffin Gish <kiffin.g...@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


_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to