how to specify current timestamps in a ->search operation in DBIx::Class?

2 messages Options
Embed this post
Permalink
kakimoto

how to specify current timestamps in a ->search operation in DBIx::Class?

Reply Threaded More More options
Print post
Permalink
hi there


 I have a question similar to
http://www.mail-archive.com/dbix-class@.../msg03106.html.


I have a postgresql db table, UserSubscriptions. Here's what it looks like:

id          integer
user_id  text
subscriptions_id  integer
name          text
active_from       timestamp with time zone
active_to  timestamp with time zone
comments  text
created_by  character varying(12)
updated_by  character varying(12)
created_on  timestamp with time zone
updated_on  timestamp with time zone


On sql, if I had wanted all entries which are active(
UserSubscriptions.active_to <= current timestamp), I would do something like

Select *
>From UserSubcriptions
Where active_to <= NOW().


I have looked through
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Manual/Intro.pod
and it suggested to look up
SQL::Abstract (http://search.cpan.org/perldoc?SQL%3A%3AAbstract).

I have looked through SQL::Abstract and well, got stuck as I don't know
how to specify "NOW()".

My question is, how do we do current time comparisons in DBIx::Class'
where clause filter for a DBIx::Class->search call please? :)

I would like to produce an sql with a where clause of "active_to <=
NOW()" as per the
example above.


thank you

K. akimoto



_______________________________________________
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@...
Tom Hukins

Re: how to specify current timestamps in a ->search operation in DBIx::Class?

Reply Threaded More More options
Print post
Permalink
On Thu, Jun 25, 2009 at 02:04:24PM +1000, [hidden email] wrote:
> I have looked through SQL::Abstract and well, got stuck as I don't know
> how to specify "NOW()".
>
> My question is, how do we do current time comparisons in DBIx::Class'
> where clause filter for a DBIx::Class->search call please? :)

The examples in the FAQ should help:
http://search.cpan.org/~ribasushi/DBIx-Class-0.08107/lib/DBIx/Class/Manual/FAQ.pod#Searching

If they don't, let us know how to improve them to make this easier to
understand.

Tom

_______________________________________________
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@...