[Dbix-class] now() - interval ? placeholder trouble

David Stevenson hoagy at ytfc.com
Tue Sep 24 23:29:53 GMT 2013


I think it fails because of the way it quotes the substituted value.

I tend to code these slightly differently. I have cases where a Perl variable has a time interval in seconds, and I've stated the SQL as "some_date + ? * INTERVAL '1 SECOND'"

Then the variable containing the number of seconds is passed as the bind param.

This isn't how one would code it as native SQL, maybe, but it works with the quoting scheme of DBIC/DBI/etc.

Cheers.

On 25 Sep 2013, at 00:10, Bob MacCallum <uncoolbob at gmail.com> wrote:

> Hello,
> 
> I can't seem to (>1h banging head against wall) get this search
> condition working
> 
> $interval = '1 hour';
> $rs->search(
> {
> birth_time => { '<' => \[ "now() - interval ?", [interval => $interval] ] }
> }
> )->count
> 
> Can anyone tell me what I'm doing wrong, please?
> 
> For more, including the runtime error, please see
> http://paste.scsys.co.uk/269786
> 
> thanks!
> Bob.
> 
> _______________________________________________
> 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




More information about the DBIx-Class mailing list