[Dbix-class] Re: now() - interval ? placeholder trouble
Dagfinn Ilmari Mannsåker
ilmari at ilmari.org
Wed Sep 25 08:18:37 GMT 2013
Bob MacCallum <uncoolbob at gmail.com> writes:
> 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
The "INTERVAL '...'" syntax (and generally TYPE '...') only works for
literal strings, not bind parameters. You need to use a cast instead,
like this: \["now() - ?::interval", $interval ]
--
"The surreality of the universe tends towards a maximum" -- Skud's Law
"Never formulate a law or axiom that you're not prepared to live with
the consequences of." -- Skud's Meta-Law
More information about the DBIx-Class
mailing list