right-hand-side MySQL functions in DBIx::Class
In DBIx::Class, when I generate a query using this syntax:
...
'Time(submitted_at)' => { '>' => 'Time(Now()-Interval ' . $wait_period . ' minute)' }
...
The generated query is perfect except for the fact that the function on the right hand side is in quotes.
... AND ( Time(submitted_at) > 'Time(Now()-Interval 5 minute)' ) ...
If it was not quoted then开发者_高级运维 it would be correct. How would I do that?
Thanks, Rob
It seems that the way to do expressions is to pass a scalar ref or array ref if you want to use literal SQL.
Here's an example showing using a query parameter for the $wait_period
variable into the expression:
...
'Time(submitted_at)' => { '>' => \['Time(Now()-Interval ? Minute)', $wait_period] }
...
Pass the string as a scalar reference instead:
...
'Time(submitted_at)' => \"> Time(Now()-Interval $wait_period minute)"
...
精彩评论