On 5/17/07, Michael Reece <[EMAIL PROTECTED]> wrote:
>      my $count = $collection->count_assets_published(
>          [ \'t2.pubdate >= NOW() - INTERVAL ? DAY' => $num_days ] #
>      );
>
> i can't refer to 'asset.pubdate' in this query param, because RDBOM
> insists i use a scalar-ref here, and wisely avoids doing
> substitutions when handed a scalar-ref, and mysql won't let me refer
> to the table by its real name once it has been aliased.. since the
> generated query aliases asset as t2, i have to use t2 here, though
> not elsewhere.  needless to day, it's a little confusing, especially
> to future-maintenance-programmer.
>
> any advice?

Two suggestions:

1. Filter $num_days to ensure it contains only integers, then add a
query parameter like this:

    'asset.pubdate' => { ge_sql => "NOW() - INTERVAL $num_days DAY" }

2. Calculate "NOW() - INTERVAL $num_days DAY" as a DateTime object and
then add a standard query param:

    'asset.pubdate' => { ge => $dt }

> seems common enough, so maybe there is already a convenient way to merge
> manager args in this case?

Not really, just standard Perl for merging arrays and so on.

-John

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Rose-db-object mailing list
Rose-db-object@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rose-db-object

Reply via email to