[Dbix-class] how to specify current timestamps in a ->search operation in DBIx::Class?

kakimoto at tpg.com.au kakimoto at tpg.com.au
Thu Jun 25 04:04:24 GMT 2009


hi there


 I have a question similar to
http://www.mail-archive.com/dbix-class@lists.scsys.co.uk/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





More information about the DBIx-Class mailing list